On Fri, Apr 04, 2003 at 11:29:24AM +0000, Neeraj Bajaj wrote:
>     Attached is an XML document that will trigger an infinite recursion in
>     Xerces2 if parsed. This is without stopping at fatal errors, but it
>     seems it cannot recover properly enough to parse the rest of the
>     document. I have found a patch to avoid the infinite recursion,
> 
> Parser behavior is not determined after it encounters fatal error. But its
> good to avoid such behavior so please send your patch.

ok, patch attached.

> There is a feature  http://apache.org/xml/features/continue-after-fatal-error
> which allows you to parse the document after it encounters fatal error, so as
> to recover further error from the document. But you should correct the XML
> file at the first place. Please read the feature documentation [1] for more
> detail.

Yes I know, I'm already using it. the problem is that I expect the
parser to recover after the wrong ENTITY declaration, in order to try to
catch more errors (if any), but with my fix it just prevents it from
doing that infinite loop, but does not help recovering. So since it
cannot recover it becomes so crooked that it reports a dozen error
messages which do not make any sense, since there was only one error.
Be warned that my patch just makes sure xerces finishes parsing with
reporting at least the ENTITY error correctly, the subsequent errors are
likely to make no sense at all.

Regards.
-- 
# Stef Epardaud, # Teachers have potentially more power than military,
# Java Defeater  #   the former can teach us how to not need the latter.
#     Earth      # Lunatech Research,
#  Solar System  #   soon we'll quit researching and start finding...
Index: src/org/apache/xerces/impl/XMLDTDScannerImpl.java
===================================================================
RCS file: 
/home/cvspublic/xml-xerces/java/src/org/apache/xerces/impl/XMLDTDScannerImpl.java,v
retrieving revision 1.38
diff -r1.38 XMLDTDScannerImpl.java
1912c1912
<         boolean again = true;
---
>         boolean again = true, fatal = false;
1979a1980,1982
>                 // we did not go forward one bit, if we don't move either
>                 // by the skipSeparator then we're in for an infinite loop
>                 fatal = true;
1981c1984,1988
<             skipSeparator(false, true);
---
>             // give this a chance to move us forward, if we saw that fatal case
>             // we need to see at least a space
>             fatal &= !skipSeparator(fatal, true);
>             if(fatal)
>                 return false;
2006a2014
> 

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

Reply via email to