Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-2239

When XMLUni::fgDOMWRTSplitCdataSections is true (the default), invalid XML characters are allowed by DOMWriter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.2.4
    • None
    • DOM
    • None
    • Operating System: All
      Platform: All

    Description

      // Create a Document with a CDATA section that contains an invalid XML character (e.g. 0x1b).
      // This should fail when serializing the Document, but it does not when XMLUni::fgDOMWRTSplitCdataSections is true.

      struct XercesDeleter
      {
      template<typename T>
      void operator()(T* data) const
      {
      if (data)

      { data->release(); }

      ;
      }
      };

      typedef std::unique_ptr<XERCES_CPP_NAMESPACE::DOMLSSerializer,XercesDeleter> DOMWriterPtr;
      typedef std::unique_ptr<XERCES_CPP_NAMESPACE::DOMDocument,XercesDeleter> DOMDocumentPtr;

      XMLPlatformUtils::Initialize();

      DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(XMLString::transcode("LS"));

       // Create DOM with a CDATA section
      DOMDocumentPtr document(impl->createDocument());

      DOMElement* element = document->createElementNS(XMLString::transcode("http://schemas.openxmlformats.org/wordprocessingml/2006/main"), XMLString::transcode("w:t"));
      document->appendChild(element);

      DOMCDATASection* codesection = document->createCDATASection(XercesString("c = '';")); // 0x1B is not a valid XML 1.0 character
      element->appendChild(codesection);

      DOMWriterPtr writer(impl->createLSSerializer());

      writer->writeToString(document.get())

      Attachments

        Activity

          People

            Unassigned Unassigned
            dleffing@mathworks.com David Leffingwell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: