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 Stef Epardaud <st...@lunatech.com> on 2003/04/03 17:04:57 UTC
Bug: infinite recursion with wrong ENTITY declaration
Hi,
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, but I'm
not happy with it because it would be better to recover from the error
after the incorrect ENTITY declaration, to allow to find more errors.
As an aside, I found that there was no message declaration for the
EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET resource.
I am ready to send my patch but would prefer a little help or guidance
in recovering better in XMLDTDScannerImpl.scanEntityDecl()
Or is it normal that any fatalError is unrecoverable and any attempt to
go further may let xerces2 loop forever ?
Thanks.
--
# 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...
Re: Bug: infinite recursion with wrong ENTITY declaration
Posted by Stef Epardaud <st...@lunatech.com>.
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...
Re: Bug: infinite recursion with wrong ENTITY declaration
Posted by Neeraj Bajaj <ne...@sun.com>.
Stef Epardaud wrote:
>Hi,
>
>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.
>but I'm
>not happy with it because it would be better to recover from the error
>after the incorrect ENTITY declaration, to allow to find more errors.
>
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.
[1] http://xml.apache.org/xerces2-j/features.html
Neeraj