unreachable code in XMLScanner::checkXMLDecl()
----------------------------------------------

                 Key: XERCESC-1641
                 URL: http://issues.apache.org/jira/browse/XERCESC-1641
             Project: Xerces-C++
          Issue Type: Bug
          Components: Non-Validating Parser
    Affects Versions: 2.7.0
         Environment: GCC 4.0.1 on PowerPC OS X 10.4.7
            Reporter: Jon Willeke
            Priority: Minor


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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to