LibXml2 internally calls stat() in an attempt to obtain information about the file (see method libxml2::xmlIO.c::xmlCheckFilename).
LibXml2 does attempt to sanitize the pathname, but only to an extent to determine if it is a valid network path or not, and to clean URI encoding problems (see method libxml2::uri.c::xmlURIUnescapeString)
Analysis:
LibXml2 does not handle name encoding problems. This shows up in passing filenames with escaped quotes. File names such as "foo\'s.nfo" and "foo''s.nfo" are valid file names but will currently fail since command line argument (for example, argv[5] in this particular bug's context) actually become "foo\\'s.nfo" and "foo's.nfo" respectively.
Possible resolution:
Notify LibXml2 team to consider this as a bug.
Resolve this within this project around xml.c::gParseOptions method.
Initial observation:
Trace:
Observations:
Next step:
Last edit: Mors Els 2018-08-07
Addtional observations:
Analysis:
Possible resolution:
Past case:
https://rt.cpan.org/Public/Bug/Display.html?id=123031 and discussion here: https://www.perlmonks.org/?node_id=1199193
Last edit: Mors Els 2018-08-08
@dmichelsen, @mgrouch, @npostavs:
I noticed LibXml2 has a similar bug: https://bugzilla.gnome.org/show_bug.cgi?id=753880
Given the similarities, do you suggest that this bug should be resolved in LibXml2 rather than here?
I think this is a bug in xmlstarlet, not libxml. Specifically, these lines in xml_select.c:do_file() before the xmlReadFile call:
Obviously, just putting single quotes around a value which itself contains single quotes is not proper quoting.
I just ran into this bug. Is there a plan to fix it? Is there a workaround?
I'm running xmlstarlet version 1.6.1
compiled against libxml2 2.9.4, linked with 20904
compiled against libxslt 1.1.29, linked with 10129
Last edit: Ken 2022-07-11