GNOME Bugzilla – Bug 583442
buggy string-range() XPointer function
Last modified: 2021-07-05 13:27:09 UTC
I discovered several flaws in the string-range() XPointer function implementation. 1. Some edge cases fail: $ ./test-xpointer '<a>xyzw</a>' "string-range(/a, 'xy', 1, 4)" -:2: element include: XInclude error : XPointer evaluation failed: #xpointer(string-range(/a, 'xy', 1, 4)) -:2: element include: XInclude error : could not load /tmp/tmp.XXXXWeW45c, and no fallback was found <?xml version="1.0"?> <root><include xmlns="http://www.w3.org/2003/XInclude" href="/tmp/tmp.XXXXWeW45c" xpointer="xpointer(string-range(/a, 'xy', 1, 4))"/></root> $ ./test-xpointer '<a>xyzw</a>' "string-range(/a, 'xy', 1, 3)" -:2: element include: XInclude error : XPointer evaluation failed: #xpointer(string-range(/a, 'xy', 1, 3)) -:2: element include: XInclude error : could not load /tmp/tmp.XXXXdTlLwI, and no fallback was found <?xml version="1.0"?> <root><include xmlns="http://www.w3.org/2003/XInclude" href="/tmp/tmp.XXXXdTlLwI" xpointer="xpointer(string-range(/a, 'xy', 1, 3))"/></root> 2. Returned strings are typically one character longer than requested: $ ./test-xpointer '<a>xyzw</a>' "string-range(/a, 'xy', 1, 2)" <?xml version="1.0"?> <root>xyz</root> 3. Searching for a single-character string triggers an infinite loop: $ ./test-xpointer '<a>xyzw</a>' "string-range(/a, 'x')" 4. Character counting is broken for non-ASCII characters: $ ./test-xpointer '<a>żółw</a>' "string-range(/a, 'żółw', 1, 4)" <?xml version="1.0"?> <root>żó</root>
Created attachment 135087 [details] test script
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.