You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading an invalid document with XML::Reader, parser errors remain stored and are falsely attributed to subsequent parses.
Example:
require"xml"
reader =XML::Reader.new(%(</foo>)) # Invalid XML
reader.read
reader.expand?
xml =XML.parse(%(<people></people>))
xml.errors # => [#<XML::Error:StartTag: invalid element name>]
A reason for that is that the XML::Reader instance is never closed to clean up. It does not even provide a method for doing that.
And even then there's the problem of global error state in libxml2. If multiple XML::Reader instance are intermingled (or an XML::Reader with XML.read), errors would be totally messed up.
A simple solution for the problem demonstrated above would be to reset errors in XML.parse and its sister methods. These methods are self-contained, so the error state could even be reset to what it was before. This would preserver functionality when called within an outer XML::Reader "session".
There's no solution for intermingled XML::Reader instances though.
When reading an invalid document with
XML::Reader
, parser errors remain stored and are falsely attributed to subsequent parses.Example:
A reason for that is that the
XML::Reader
instance is never closed to clean up. It does not even provide a method for doing that.And even then there's the problem of global error state in libxml2. If multiple
XML::Reader
instance are intermingled (or anXML::Reader
withXML.read
), errors would be totally messed up.A simple solution for the problem demonstrated above would be to reset errors in
XML.parse
and its sister methods. These methods are self-contained, so the error state could even be reset to what it was before. This would preserver functionality when called within an outerXML::Reader
"session".There's no solution for intermingled
XML::Reader
instances though.This bug was discovered through spec randomization in #12541 (https://github.com/crystal-lang/crystal/actions/runs/3303805339/jobs/5452171721).
The text was updated successfully, but these errors were encountered: