8209615: ParseError in XMLEventReader on a valid input
authorjoehw
Wed, 22 Aug 2018 14:28:47 -0700
changeset 51502 b5ca7ff199db
parent 51501 535cce23fa8b
child 51503 0265a70ea2a5
8209615: ParseError in XMLEventReader on a valid input Reviewed-by: lancea
src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Wed Aug 22 13:53:48 2018 -0700
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java	Wed Aug 22 14:28:47 2018 -0700
@@ -1634,6 +1634,8 @@
                     }
                 } else {
                     //CData partially returned due to the size limit
+                    fInCData = true;
+                    fCDataEnd = false;
                     break;
                 }
                 //by this time we have also read surrogate contents if any...
@@ -2928,7 +2930,11 @@
                         fUsebuffer = true;
                         //CDATA section is read up to the chunk size limit
                         scanCDATASection(fContentBuffer , true);
-                        setScannerState(SCANNER_STATE_CONTENT);
+                        if (!fCDataEnd) {
+                            setScannerState(SCANNER_STATE_CDATA);
+                        } else {
+                            setScannerState(SCANNER_STATE_CONTENT);
+                        }
                         //1. if fIsCoalesce is set to true we set the variable fLastSectionWasCData to true
                         //and just call fDispatche.next(). Since we have set the scanner state to
                         //SCANNER_STATE_CONTENT (super state) parser will automatically recover and
@@ -2941,9 +2947,6 @@
                             //there might be more data to coalesce.
                             continue;
                         } else if(fReportCdataEvent) {
-                            if (!fCDataEnd) {
-                                setScannerState(SCANNER_STATE_CDATA);
-                            }
                             return XMLEvent.CDATA;
                         } else {
                             return XMLEvent.CHARACTERS;