Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line number of RelaxNG error seems capped at 65535 #1505

Closed
mikevm opened this issue Jul 7, 2016 · 2 comments
Closed

Line number of RelaxNG error seems capped at 65535 #1505

mikevm opened this issue Jul 7, 2016 · 2 comments

Comments

@mikevm
Copy link

mikevm commented Jul 7, 2016

When validating an XML document using RelaxNG, the line number of the error is capped at 65535.

test code: https://gist.github.com/mikevm/71095581645c62a971194b3142d09b92

output:

$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
$ ruby ./test.rb
Nokogiri: 1.6.8
XML document with a schema violation on line 400
 0. RelaxNG reports error on line 400: Error validating datatype string
 1. RelaxNG reports error on line 400: Element item failed to validate content
XML document with a schema violation on line 40000
 0. RelaxNG reports error on line 40000: Error validating datatype string
 1. RelaxNG reports error on line 40000: Element item failed to validate content
XML document with a schema violation on line 70000
 0. RelaxNG reports error on line 65535: Error validating datatype string
 1. RelaxNG reports error on line 65535: Element item failed to validate content

expected the result of #line always returns the line on which the error occurred
actual the result of #line is capped at 65535.

@larskanis
Copy link
Member

In fact this is a shortcoming in libxml2. We can not fix it in nokogiri and it probably will not be fixed in libxml2. See: https://mail.gnome.org/archives/xml/2012-August/msg00168.html

flavorjones added a commit that referenced this issue Aug 14, 2021
- set BIG_LINES parse option by default which will allow Node#line to return large integers
- allow Node#line= to set large line numbers on text nodes

Fixes #1764, #1493, #1617, #1505, #1003, #533
flavorjones added a commit that referenced this issue Aug 14, 2021
feat(cruby): support line numbers larger than a short

---

**What problem is this PR intended to solve?**

As noted in #1493, #1617, #1505, #1003, and #533, libxml2 has not historically supported line numbers greater than a `short int`. Starting in libxml v2.9.0, setting the parse option `BIG_LINES` would allow tracking line numbers in longer documents.

Specifically this PR makes the following changes:

- set `BIG_LINES` parse option by default which will allow `Node#line` to return large integers
- allow `Node#line=` to set large line numbers on text nodes

Fixes #1764 

**Have you included adequate test coverage?**

Yes!

**Does this change affect the behavior of either the C or the Java implementations?**

JRuby's Xerces-based implementation did not suffer from this particular shortcoming, although its line number functionality is questionable in other ways (see #2177 / b32c875).
@flavorjones
Copy link
Member

This will be fixed in v1.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants