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

unreachable code in XMLScanner::checkXMLDecl()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.7.0
    • 2.8.0
    • Non-Validating Parser
    • None
    • GCC 4.0.1 on PowerPC OS X 10.4.7

    Description

      While investigating a failure in the XML conformance test suite (xmltest/not-wf/sa/154.xml) on IA64 Windows, I stepped through a debug build of SAXPrint and libxerces on OS X. The document has an XML declaration with an uppercase "XML":

      <?XML version="1.0"?>
      <doc></doc>

      The XMLScanner::checkXMLDecl() method in XMLScanner.cpp appears to have a special case to accept this, but emit the XMLErrs::XMLDeclMustBeLowerCase error. However, this code is not reachable, as it resides within an if statement that looks for lowercase "<?xml." If I move the test out a level, it is reachable; e.g.:

      if (startWithAngle) {
      if (peekString (fgXMLDeclString))
      {
      if (skippedString (fgXMLDeclStringSpace)

      ...) { ... }

      /* move from here ... */
      }
      /* ... to here */
      else if (skippedString (fgXMLDeclStringSpaceU)

      ...) { ... }

      }

      As it is, the document is properly rejected with the XMLErrs::NoPIStartsWithXML error, so it may also be acceptable to simply remove the condition. svn blame is broken (and this code appears to predate svn), but Google helped me find that this condition is an original part of the function, which was added by Tinny Ng in June of 2001, in response to Bugzilla 2257.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jwilleke Jon Willeke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: