From 1f5ad0469d2efdff38aad3f84107f8d3b47f0c0a Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Tue, 16 Jul 2002 15:35:44 +0000
Subject: [PATCH] [Bug 6590] Improper Internal subset filling.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174015 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp |  5 ++++
 src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp |  1 +
 src/xercesc/parsers/AbstractDOMParser.cpp    | 29 ++++++++++++++------
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp b/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp
index 96e4180ca..b7919f215 100644
--- a/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp
+++ b/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp
@@ -370,6 +370,11 @@ void        DOMDocumentTypeImpl::appendInternalSubset(const XMLCh *value)
     internalSubset.append(value);
 }
 
+void        DOMDocumentTypeImpl::appendInternalSubset(const XMLCh toAppend)
+{
+    internalSubset.append(toAppend);
+}
+
 void DOMDocumentTypeImpl::release()
 {
     if (fNode.isOwned()) {
diff --git a/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp b/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp
index 131cb11ff..5075d6418 100644
--- a/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp
+++ b/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp
@@ -104,6 +104,7 @@ private:
     virtual void        setSystemId(const XMLCh * value);
     virtual void        setInternalSubset(const XMLCh *value);
     void                appendInternalSubset(const XMLCh *value);
+    void                appendInternalSubset(const XMLCh toAppend);
     bool                isIntSubsetReading() const;
 
     friend class AbstractDOMParser;
diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp
index 42af94de3..8adb02c7f 100644
--- a/src/xercesc/parsers/AbstractDOMParser.cpp
+++ b/src/xercesc/parsers/AbstractDOMParser.cpp
@@ -795,7 +795,7 @@ void AbstractDOMParser::attDef
     const   DTDElementDecl&     elemDecl
     , const DTDAttDef&          attDef
     , const bool                ignoring
-	)
+)
 {	
     if (fDocumentType->isIntSubsetReading())
     {
@@ -804,13 +804,6 @@ void AbstractDOMParser::attDef
             XMLBufBid bbQName(&fBufMgr);
             XMLBuffer& attString = bbQName.getBuffer();
 
-            attString.append(chOpenAngle);
-            attString.append(chBang);
-            attString.append(XMLUni::fgAttListString);
-            attString.append(chSpace);
-            attString.append(elemDecl.getFullName());
-
-            attString.append(chSpace);
             attString.append(attDef.getFullName());
 
             // Get the type and display it
@@ -902,7 +895,6 @@ void AbstractDOMParser::attDef
                 attString.append(chDoubleQuote);
             }
 
-            attString.append(chCloseAngle);
             fDocumentType->appendInternalSubset(attString.getRawBuffer());
         }
     }
@@ -1014,6 +1006,12 @@ void AbstractDOMParser::endAttList
     const   DTDElementDecl& elemDecl
 )
 {
+    if (fDocumentType->isIntSubsetReading())
+    {
+        //print the closing angle
+        fDocumentType->appendInternalSubset(chCloseAngle);
+    }
+
 	// this section sets up default attributes.
 	// default attribute nodes are stored in a NamedNodeMap DocumentTypeImpl::elements
 	// default attribute data attached to the document is used to conform to the
@@ -1208,6 +1206,19 @@ void AbstractDOMParser::startAttList
     const   DTDElementDecl& elemDecl
 )
 {
+    if (fDocumentType->isIntSubsetReading())
+    {
+        XMLBufBid bbQName(&fBufMgr);
+        XMLBuffer& attString = bbQName.getBuffer();
+
+        attString.append(chOpenAngle);
+        attString.append(chBang);
+        attString.append(XMLUni::fgAttListString);
+        attString.append(chSpace);
+        attString.append(elemDecl.getFullName());
+
+        fDocumentType->appendInternalSubset(attString.getRawBuffer());
+    }
 }
 
 void AbstractDOMParser::startIntSubset()
-- 
GitLab