Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8153781

Issue in XMLScanner: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET when skipping large DOCTYPE section with CRLF at wrong place

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: xml
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b116

      Backports

        Description

        Under certain circumstances, the following exception might occur during XML scanning:
        Exception in thread "main" java.util.MissingResourceException: EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET
                at com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter.formatMessage(java.xml@9-internal/XMLMessageFormatter.java:99)
                at com.sun.xml.internal.stream.StaxErrorReporter.reportError(java.xml@9-internal/StaxErrorReporter.java:93)
                at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(java.xml@9-internal/XMLScanner.java:1444)
                at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(java.xml@9-internal/XMLDocumentScannerImpl.java:1109)
                at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(java.xml@9-internal/XMLDocumentScannerImpl.java:1044)
                at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(java.xml@9-internal/XMLDocumentScannerImpl.java:932)
                at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(java.xml@9-internal/XMLDocumentScannerImpl.java:601)
                at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(java.xml@9-internal/XMLNSDocumentScannerImpl.java:111)
                at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(java.xml@9-internal/XMLStreamReaderImpl.java:553)
                at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(java.xml@9-internal/XMLEventReaderImpl.java:83)
                at com.sap.cl.xml.test.XMLEventReaderTest.main(XMLEventReaderTest.java:39)

        Following is a small test to reproduce the behavior:
        public static void main(String[] args) throws Exception {
        StringBuilder xmlcontentbuilder = new StringBuilder(XMLEntityManager.DEFAULT_BUFFER_SIZE * 2);
        xmlcontentbuilder.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n");
        xmlcontentbuilder.append("<!DOCTYPE dummy [\r\n");
        xmlcontentbuilder.append(" <!ELEMENT dummy EMPTY>\r\n");
        xmlcontentbuilder.append(" <!--\r\n");
        xmlcontentbuilder.append(" ");
        int textlen = XMLEntityManager.DEFAULT_BUFFER_SIZE - xmlcontentbuilder.length() - 2 - 1;
        for (int i = 0; i < textlen; i++)
        xmlcontentbuilder.append('a');
        xmlcontentbuilder.append("\r\n");
        xmlcontentbuilder.append(" -->\r\n");
        xmlcontentbuilder.append(" ]\r\n");
        xmlcontentbuilder.append(">\r\n");
        xmlcontentbuilder.append("<dummy>\r\n");
        xmlcontentbuilder.append("</dummy>\r\n");

        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
        StringReader stringReader = new StringReader(xmlcontentbuilder.toString());
        XMLEventReader reader = factory.createXMLEventReader(stringReader);

        while (reader.hasNext()) {
        XMLEvent event = reader.nextEvent();
        System.out.println("Event Type: " + event.getEventType());
        }
        }

          Activity

          Hide
          clanger Christoph Langer added a comment -
          Source to reproduce behavior
          Show
          clanger Christoph Langer added a comment - Source to reproduce behavior
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/dev/jaxp/rev/8be2998d17d6
          User: joehw
          Date: 2016-04-20 06:01:47 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jaxp/rev/8be2998d17d6 User: joehw Date: 2016-04-20 06:01:47 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jaxp/rev/8be2998d17d6
          User: lana
          Date: 2016-04-27 18:46:16 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jaxp/rev/8be2998d17d6 User: lana Date: 2016-04-27 18:46:16 +0000

            People

            • Assignee:
              clanger Christoph Langer
              Reporter:
              clanger Christoph Langer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: