You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by David Parker <dp...@ebt.com> on 2000/11/30 18:20:28 UTC

handling empy InputSource

Using xerces 1.2.1, if an InputSource gets created from a 0-length file, the
XMLDocumentScanner.parseSome() method goes into an infinite loop in its
calls to the XMLDocumentScanner.XMLPrologDispatcher.dispatch() method.

The problem is that the dispatch() method falls through to the end of the
do-while loop, where fScannerState == SCANNER_STATE_END_OF_INPUT, and
returns true without the fDispatcher ever having been re-created with
another type of dispatcher. So the parseSome() method just keeps calling
XMLPrologDispatcher.dispatch() and looping infinitely.

Under normal circumstances, the fDispatcher would be set to a
ContentDispatcher on the return from XMLPrologDispatcher.dispatch(). Normal
operation is to eventually reach an EndOfInputDispatcher fDispatcher, which
will return false, and the parseSome() method can finally pack up and go
home....

- DAP

-----------------------------------------------------------
David Parker - eBusiness Technologies - (401) 752-4497

"If we become too serious we will lose our way."
                                         - Shunryu Suzuki


RE: handling empy InputSource

Posted by David Parker <dp...@ebt.com>.
Changing XMLDocumentScanner.PrologDispatcher.dispatch() to return false when
it falls through the do-while loop appears to fix the problem. Attached is
the modified version of XMLDocumentScanner.java (from the 1.2.2 release -
not taken from cvs). The only change is line 912.

- DAP

> -----Original Message-----
> From: David Parker [mailto:dparker@ebt.com]
> Sent: Thursday, November 30, 2000 12:20 PM
> To: xerces-j-dev@xml.apache.org
> Subject: handling empy InputSource
>
>
> Using xerces 1.2.1, if an InputSource gets created from a
> 0-length file, the
> XMLDocumentScanner.parseSome() method goes into an infinite loop in its
> calls to the XMLDocumentScanner.XMLPrologDispatcher.dispatch() method.
>
> The problem is that the dispatch() method falls through to the end of the
> do-while loop, where fScannerState == SCANNER_STATE_END_OF_INPUT, and
> returns true without the fDispatcher ever having been re-created with
> another type of dispatcher. So the parseSome() method just keeps calling
> XMLPrologDispatcher.dispatch() and looping infinitely.
>
> Under normal circumstances, the fDispatcher would be set to a
> ContentDispatcher on the return from
> XMLPrologDispatcher.dispatch(). Normal
> operation is to eventually reach an EndOfInputDispatcher
> fDispatcher, which
> will return false, and the parseSome() method can finally pack up and go
> home....
>
> - DAP
>
> -----------------------------------------------------------
> David Parker - eBusiness Technologies - (401) 752-4497
>
> "If we become too serious we will lose our way."
>                                          - Shunryu Suzuki
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org

RE: handling empy InputSource

Posted by David Parker <dp...@ebt.com>.
I just verified that I get the same behavior in xerces 1.2.2.

- DAP

> Using xerces 1.2.1, if an InputSource gets created from a 
> 0-length file, the
> XMLDocumentScanner.parseSome() method goes into an infinite loop in its
> calls to the XMLDocumentScanner.XMLPrologDispatcher.dispatch() method.
> 
> The problem is that the dispatch() method falls through to the end of the
> do-while loop, where fScannerState == SCANNER_STATE_END_OF_INPUT, and
> returns true without the fDispatcher ever having been re-created with
> another type of dispatcher. So the parseSome() method just keeps calling
> XMLPrologDispatcher.dispatch() and looping infinitely.
> 
> Under normal circumstances, the fDispatcher would be set to a
> ContentDispatcher on the return from 
> XMLPrologDispatcher.dispatch(). Normal
> operation is to eventually reach an EndOfInputDispatcher 
> fDispatcher, which
> will return false, and the parseSome() method can finally pack up and go
> home....
> 
> - DAP
> 
> -----------------------------------------------------------
> David Parker - eBusiness Technologies - (401) 752-4497
> 
> "If we become too serious we will lose our way."
>                                          - Shunryu Suzuki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org

RE: handling empy InputSource

Posted by Lynn Monson <lm...@flipdog.com>.
An infinite loop also occurs for the following input file:

<root

I know it's syntactically illegal, but the parser infinite loops in a
similar fashion to the empty document.