For others' benefit… After diving into Andrew Watt's "XPath Essentials" from 2002, seasoned with a bit of googling, here's the solution: xml.exe sel -B -t -m "//item" -v "title" -n -v "guid" -n -v "enclosure/@url" -n -n test.xml
Hello, I assume it can be done with XmlStarlet but it requires XPath kung-fu way above my head. I need to grab an RSS feed using wget, and then feed it to XmlStarlet to grab a few sibings from each item: wget -qO - https://feeds.acme.com/feed/rss.xml |xmlstarlet\xml.exe sel -t <magic here=""></magic> =========== rss/channel/item THIS rss/channel/item/title THIS rss/channel/item/guid rss/channel/item/guid/@isPermaLink rss/channel/item/description rss/channel/item/content:encoded THIS rss/channel/item/pubDate...
Sorry, I mangled the report. The broken test case is xmlstarlet unesc "ö"
Sorry, I mangled the report. The broken test case is xmlstarlet unesc "ö"
Sorry, I mangled the report. The broken test case is xmlstarlet unesc "&x246;"
unesc ignores locale
That patch still results in errors when building this on Fedora rawhide. The attach patch fixes all errors and some const warnings.
Fix build with libxml2-2.12
Second one looks lie has been created in 2016 and since then nothing has been done
Just seach for xmlstarlet, e.g. https://github.com/dimitern/xmlstarlet https://github.com/fishjam/xmlstarlet
OK so where are those forks?
Hi Tomasz, there are already some forks of Github. I would say maintenance here is on a fairly low level at the moment. Feel free to fork on Github and proceed with your ideas! Best regards -- Dago
Move git repo to github/gilab or organize live mirror
Is it possible to merge this patch?
Hello everyone. I have xml document with structure like this: <pts <table <rows <row p00="some_id" p01="some_1 value_1" <row p00="some_id_2" p01="some_2 value_2" <rows <table <pts I need to get value from attribute p01. I try this command: xmlstarlet sel -T -t -v "/pts/table/rows/row/@p01" file.xml. And get value i need, but all values split by whitespace like this: "some_1" "value_1" "some_2" "value_2" but i need it like this "some_1 value_1" "some_2 value_2".
Hello everyone. I have xml document with structure like this: pts table rows row p00="some_id" p01="some_1 value_1" row p00="some_id_2" p01="some_2 value_2" rows table pts I need to get value from attribute p01. I try this command: xmlstarlet sel -T -t -v "/pts/table/rows/row/@p01" file.xml. And get value i need, but all values split by whitespace like this: "some_1" "value_1" "some_2" "value_2" but i need it like this "some_1 value_1" "some_2 value_2".
Hello everyone. I have xml document with structure like this: pts table rows row p00="some_id" p01="some_1 value_1" row p00="some_id_2" p01="some_2 value_2" rows table pts I need to get value from attribute from attribute p01. I try this command: xmlstarlet sel -T -t -v "/pts/table/rows/row/@p01" file.xml. And get value i need, but all values split by whitespace like this: "some_1" "value_1" "some_2" "value_2" but i need it like this "some_1 value_1" "some_2 value_2".
Hello everyone. I have xml document with structure like this: pts table rows row p00="some_id" p01="some_1 value_1" row p00="some_id_2" p01="some_2 value_2" rows table pts I need to get value from attribute from attribute p01. I try this command: xmlstarlet sel -T -t -v "/pts/table/rows/row/@p01" file.xml. And get value i need, but all values split by whitespace like this: "some_1" "value_1" "some_2" "value_2" but i need it like this "some_1 value_1" "some_2 value_2".
Hello everyone. I have xml document with structure like this: <pts> </pts>
Hello everyone. I have xml document with structure like this: <pts> </pts>
Thanks for this fix, I have applied it now in Gentoo Linux https://github.com/gentoo/gentoo/commit/0f0ba1c7b1f617b17eb0b946a5f63e92b3320a01
For the xml you posted I would go with xmlstarlet sel --noblanks --text -t -m //item -v title -v description weewx_rss-xx.xml, but the RSS you linked looks a bit different, so it looks like just xmlstarlet sel --noblanks --text -t -v //item weewx_rss.xml would work.
Hi I need to extract a simple line of text from an xml file generated by my weather software. I can then present this as a variable to ffmpeg to introduce a timestamp on a video. I am a total code noob who just does not get most code so please be gentle! The xml is: Snip: <item> <title>Weather Conditions at 11/04/23 18:20:00</title> <link>http://www.wslwx.co.uk <description> Outside Temperature: 7.8°C; Barometer: 998.4 hPa; Wind: 6 mph from 142°; Rain Rate: 1.7 mm/h; Garage Temperature: 12.7°C </description>...
Fix --comp option
Too aggressive RegExp in documentation
Fix build with clang16
The correct sintax to replace in this case is with "-x" instead "-v" to eval expressions. Regards.
Hi, I'm trying to concat values in Windows OS and the result is the string without processing, with quote or double quotes. For example: xml.exe edit --inplace -N xmlns="http://maven.apache.org/POM/4.0.0" -u "//xmlns:groupId[starts-with(., 'org.company')]" -v "//xmlns:groupId[concat(substring-before(., 'org.company'), 'new', substring-after(., 'org.company'))]" pom.xml Result: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0...
Hi, I'm trying to concat values in Windows OS and the result is the string without processing, with quote or double quotes. For example: xml.exe edit --inplace -N xmlns="http://maven.apache.org/POM/4.0.0" -u "//xmlns:groupId[starts-with(., 'org.jacoco')]" -v "//xmlns:groupId[concat(substring-before(., 'org.jacoco'), 'new', substring-after(., 'org.jacoco'))]" pom.xml Result: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0...
Thank you. it confirms my reasoning too. But the syntactical problem is aggravated if there are just two b elements. In this case the command line looks like xmlstarlet ed -P -S -d '/a/b[1]' -d '/a/b' test.xml | xmlstarlet format -s 4 - which is quite counter intuitive. I respect the designer's decision but would have preferred it otherwise as in the case where the command line is itself generated through scripts.
Thank you. i thought so. But the syntactical problem is aggravated if there are just two b elements. In this case the command line looks like xmlstarlet ed -P -S -d '/a/b[1]' -d '/a/b' test.xml | xmlstarlet format -s 4 - which is quite counter intuitive. I respect the designer's decision but would have preferred it otherwise as in the case where the command line is itself generated through scripts.
Hi Sridhar, the modifies are processed in order and are especially not applied all-at-once to the originating tree. This means you first delete the first element (10) leaving two elements (20, 30), than you delete the second element from this result (30), so the remained is 20. If you want to delete the first two elements you can do so by xmlstarlet ed -P -S -d '/a/b[1]' -d '/a/b[1]' test.xml | xmlstarlet format -s 4 -
issue when ed -d (delete) is specified multiple times
Hello, I can't find the solution and spend hours for looking it. I hope that someone can help me. I have the following XML file from which I want to read the invoice number. The xml file starts with: <?xml version="1.0" encoding="utf-8"?> <Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"> <CustomizationID xmlns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.1</CustomizationID> <ProfileID...
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
I just ran into this bug. Is there a plan to fix it? Is there a workaround?
It is good to have namespace for xml, but specify namespace in xpath is troublesome. In xslt 2.0, one can specify default namespace for xpath, but libxml2 does not support xslt 2.0. In xmlstarlet, one can use --doc-namespace, and _ will refer to the default namespace, but it is still troublesome to write every element with prefix. This patch add a --ignore-default-namespace option, which work in xml select and xml edit. This option will remove default namespace in xml tree, so xpath without prefix...
It is good to have namespace for xml, but specify namespace in xpath is troublesome. In xslt 2.0, one can specify default namespace for xpath, but libxml2 does not support xslt 2.0. In xmlstarlet, one can use --doc-namespace and _ will refer to default namespace, but it is still troublesome to write every element with prefix. This patch add a --ignore-default-namespace option, which work in xml select and xml edit. This option will remove default namespace in xml tree, so xpath without prefix can...
Also elements such as for example same desired output: 20210506183519
Hi I am trying to extract all the time values from a set of xml files. I am confused at the proper syntax. Can anyone help? Examples of entries with time values are as follows: <effectivetime><low value="20210101000000"><high value="20211231235959"></high></low></effectivetime> The result I want is: 20210506183519 20210101000000 20211231235959 The proper syntax for this is eluding me. I've fumbled around a lot without success such as: xmlstarlet sel -N x="urn:hl7-org:v3" -t -c //x:effectiveTime -v...
Hello, I'm only getting started with XPath, know nothing about XSLT, and was wondering if I could use XmlStarlet to perform the following tasks on KML files: If the file contains… 1. A /kml/Document/name, change its value to the filename (eg. myfile.kml); If the element/node doesn't exist, insert one 2. One or more LineString (track) elements, insert a sibling: <style><LineStyle><color>FF0000FF</color><width>6</width></LineStyle></style> 3. One or more Point (waypoints), insert a sibling: <styleurl>#placemark-green</styleurl>...
Totally agree. Usage example from stackoverflow uses xmlstarlet binary name whereas built from source version on my ubuntu has 'xml' name which is a bit frustrating.
I find that the above sequence will not be handled corrently by the 'unesc' command: echo '"' | xmlstarlet unesc entity name too long: " " It looks to me like the length check is one-off. The patch below works for me, but not 100% sure that it doesn't create a buffer overrun. --- src/xml_escape.c.orig 2021-01-09 11:26:11.363863708 +0100 +++ src/xml_escape.c 2021-01-09 11:26:17.678959009 +0100 @@ -222,7 +222,7 @@ semicolon_off++; } entity_len = semicolon_off - i; - if (entity_len < MAX_ENTITY_NAME)...
Hello everyone. I need help: I have an XML file with this structure: <?xml version="1.0"?> <!DOCTYPE datafile PUBLIC "-//Logiqx//DTD ROM Management Datafile//EN" "http://www.logiqx.com/Dats/datafile.dtd"> <datafile> <header> <name>Nintendo - GameCube</name> <description>Nintendo - GameCube - Discs (1866) (2019-01-17 00-50-37)</description> <version>2019-01-17 00-50-37</version> <date>2019-01-17 00-50-37</date> <author>redump.org</author> <homepage>redump.org</homepage> <url>http://redump.org/</url>...
Just a heads-up. The last release (xmlstarlet v1.6.6) I just pushed to https://pypi.org/project/xmlstarlet works quite nicely. I'm happy to say (after a lot of trial and error) I got the building of binary wheels for Python 3.6+ on Linux, MacOS, and Windows automated. P.S. Building on Windows proved quite challenging, I have to say. I got a MingGW64-based build to work using the master branch's mingw/GNUmakefile as a starting point, modified to use pre-built binaries of libxml2 / libxslt for x86_64...
Hello, we are not able to execute xml starlet commands in our project. We have got the following error: .:/tmp>/usr/bin/xml sel -T -t -v '///MetaData[1]/MessageGroup[1]' datafileexample.xml datafileexample.xml:52: error: xmlSAX2Characters: huge text node: out of memory* According to my research the problem seems to be in the library libxml2. Is there any possibility for xml starlet to cope with this problem? xmllint has a command line parameter that allows it to overcome the limit of 10 MG for XML...
given the attached xml file, can xmlstarlet follow the "include=" and also load that/those files to work with?
Use PKG_CHECK_MODULES to find libxml2 and lib(e)xslt
Hi, could anyone help if how is it possible to validate around 200 documents at once against XSD? Thank you in advance
It's working - I have binary wheels published for Linux and MacOSX, as well as the source distribution. It took some time to get all the details right, but I'm happy to report it works as expected.
Hello! Thank you for the great tool! I've been using it a lot for XML processing from Python, as an external tool. Lately I've been looking for a way to use it more efficiently, and managed to get working CFFI-based Python extension that allows direct access to the main functions of all commands from Python. Here's the repository: https://github.com/dimitern/xmlstarlet There seems to be some issues to publish Linux binary wheels on https://pypi.org, but locally it works on Linux and Mac OS X at least....
Thank you the solution worked!!
See http://xmlstar.sourceforge.net/doc/UG/ch05.html
I have package.xml as follows <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>HeatMap</members> <name>ApexPage</name> </types> <version>38.0</version> </package> and i am trying to add new members element using the following command xml ed -s "/Package/types[name='ApexPage']" -t elem -n members -v "DreamHouseSampleData" package.xml Expected Result: <package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>HeatMap</members>...
Hi, I'm trying to modifiy the Value Office2010Blue in this document... so far any command I tried end with no error but still the file is not updated... I need to change the value to Office2010dark but my knowledge in xml is not good enough to understand what I need to do. I fiddled with xml.exe a bit an read a whole bunch of infos but I can't find what i miss... xml ed -L -u "/Root/key[1]/key[2]/ValueKey[1][@Name=ActiveSkin]/@value" -v "Office2010dark" AppRegistry.xml Don't laugh ;) <?xml version="1.0"...
Hi, I'm trying to modifiy the Value Office2010Blue in this document... so far any command I tried end with no error but still the file is not updated... I need to change the value of Office2010Light but my knowledge in xml is not good enough to understand what I need to do. I fiddled with xml.exe a bit an read a whole bunch of infos but I can't find what i miss... xml ed -L -u "/Root/key[1]/key[2]/ValueKey[1][@Name=ActiveSkin]/@value" -v "Office2010dark" AppRegistry.xml Don't laugh ;) <?xml version="1.0"...
Thanks a million This fixed everything. xml ed -L -u "/Root/Key[1]/Key[2]/ValueKey[1][@Name='ActiveSkin']/@Value" -v "It Worked !!!" AppRegistry.xml
... "/Root/key[1]/key[2]/.../@value" ... Node names are case-sensitive, so use Key and Value. ... "/Root/...[@Name=ActiveSkin]..." You want to compare against string value, so use @Name='ActiveSkin'.
Hi, I'm trying to modifiy the Value Office2010Blue in this document... so far any command I tried end with no error but still the file is not updated... I need to change the value to Office2010Light but my knowledge in xml is not good enough to understand what I need to do. I fiddled with xml.exe a bit an read a whole bunch of infos but I can't find what i miss... xml ed -L -u "/Root/key[1]/key[2]/ValueKey[1][@Name=ActiveSkin]/@value" -v "Office2010dark" AppRegistry.xml Don't laugh ;) <?xml version="1.0"...
Hi, I'm trying to modifiy the Value Office2010Blue in this document... so far any command I tried end with no error but still the file is not updated... I need to change the value to Office2010Light but my knowledge in xml is not good enough to understand what I need to do. I fiddled with xml.exe a bit an read a whole bunch of infos but I can't find what i miss... xml ed -L -u "/Root/key[1]/key[2]/ValueKey[1][@Name=ActiveSkin]/@value" -v "Office2010dark" Conf.xml Don't laugh ;) <?xml version="1.0"...
Using XMLStarlet 1.6.1, what is the best practice to replace a substring in a value? For instance I'd like to modify an attribute's value: http://www.domain.com/cgi?param1=foo&param2={bar} in order to receive: http://www.domain.com/cgi?param2={bar} (A separate problem might be the "&" char of "&", at least it can be tricky in a cmd environment.) Is there a straightforward method like s/param1=foo&// to apply?
Seems i hit the same issue and in searching for the fix, came across this old bug report. I tried to use my original sed but seems the comment lost something in translation (at least the ([^ ]) should have a tab in there but still it doesnt work and i cannot remember how it should be. Luckily, i found this alternative below which works so just wanted to update here in case anyone else is looking for this fix. sed -E 's#<([^/ ]+)/>#<\1>#g' filename.xml > filename,new From https://unix.stackexchan...
cat sample.xml <sample> <permission name="android.permission.WRITE_MEDIA_STORAGE" > <group gid="media_rw" /> <group gid="sdcard_rw" /> </permission> <permission name="android.permission.WRITE_EXTERNAL_STORAGE" /> </sample> cat sample.xml | xml ed -s '//permission[@name="android.permission.WRITE_MEDIA_STORAGE"]' -t elem -n 'group gid="sdcard_all"' | xml ed -s '//permission[@name="android.permission.WRITE_EXTERNAL_STORAGE"]' -t elem -n 'group gid="sdcard_r"' | xml ed -s '//permission[@name="android.permission.WRITE_EXTERNAL_STORAGE"]'...
cat sample.xml <sample> <permission name="android.permission.WRITE_MEDIA_STORAGE" > <group gid="media_rw" /> <group gid="sdcard_rw" /> </permission> <permission name="android.permission.WRITE_EXTERNAL_STORAGE" /> </sample> cat sample.xml | xml ed -L -s '//permission[@name="android.permission.WRITE_MEDIA_STORAGE"]' -t elem -n 'group gid="sdcard_all"' | xml ed -L -s '//permission[@name="android.permission.WRITE_EXTERNAL_STORAGE"]' -t elem -n 'group gid="sdcard_r"' | xml ed -L -s '//permission [@name="android.permission.WRITE_EXTERNAL_STORAGE"]'...
cat sample.xml <permission name="android.permission.WRITE_MEDIA_STORAGE"> <group gid="media_rw"> <group gid="sdcard_rw"> </group></group></permission> cat sample.xml | xml ed -L -a '//group[@gid="sdcard_rw"]' -t elem -n 'group gid="sdcard_all"' -v "" <?xml version="1.0"?> <permission name="android.permission.WRITE_MEDIA_STORAGE"> <group gid="media_rw"> <group gid="sdcard_rw"> <group gid="sdcard_all"> </group></group></group></permission>
Thanks Noam! That works. Would be good to explain that in the help output. I think this ticket can be closed now.
' being replaced by ' in the output xml. Any ideas why this is occuring Xmlstarlet works by reading in and parsing the XML data into a tree, in parsed form there is no distinction between ' and ' . and how I can avoid it from happening? Don't use Xmlstarlet.
Use - to indicate stdin, e.g., cat a.xml | xmlstarlet val --xsd b.xsd --err -
xmlstarlet val: Consistent message order
Workaround I'm using (inside a Dockerfile): mkdir -p /io cat > /io/input.xml xmlstarlet validate --xsd "$1" --err /io/input.xml
Allow val to read from stdin
I'm running some commands to delete specific nodes, but I've noticed that other lines in my xml files are being affected, specifically I've seen'being replaced by ' in the output xml. Any ideas why this is occuring and how I can avoid it from happening? Thanks. Running this command:xml ed -d "/xml/table/rec[@id='2']" xml/table.xml Input XML value <xml> <table> <rec id="1"> <stringField>a</stringField> </rec> <rec id="2"> <stringField>b</stringField> </rec> <rec id="3"> <stringField>That's...
I'm running some commands to delete specific nodes, but I've noticed that other lines in my xml files are being affected, specifically I've seen'being replaced by ' in the output xml. Any ideas why this is occuring and how I can avoid it from happening? Thanks. Running this command:xml ed -d "/xml/table/rec[@id='2']" xml/table.xml Input XML value <xml> <table> <rec id="1"> <stringField>a</stringField> </rec> <rec id="2"> <stringField>b</stringField> </rec> <rec id="3"> <stringField>That's...
I'm running some commands to delete specific nodes, but I've noticed that other lines in my xml files are being affected, specifically I've seen'being replaced by ' in the output xml. Any ideas why this is occuring and how I can avoid it from happening? Thanks. Running this command:xml ed -d "/xml/table/rec[@id='2']" xml/table.xml Input XML value <xml> <table> <rec id="1"> <numField>123</numField> <stringField>String Value</stringField> </rec> <rec id="2"> <numField>346</numField> <stringField>Text...
The 1.6.1 release of the snap is now published to the stable channel, here's the updated install instructions: sudo snap install xmlstarlet I will file a merge request to upstream the packaging in the near future.
The snap is now published to the beta channel, here's the updated install instructions: # Install the snap package # sudo snap install --channel=beta xmlstarlet # Connect the snap to optional security confinement interfaces # ## For accessing files under `/mnt` or `/media` ## sudo snap connect xmlstarlet:removable-media # Launch the application # xmlstarlet snap run xmlstarlet # If you have another existing installation xmlstarlet.xml # You can also run `xml` directly after running `sudo snap alias...
The 1.6.1 release of the snap is now published to the stable risk level, here's the updated install instructions: sudo snap install xmlstarlet I will file a merge request to upstream the packaging in the near future.
Implement snap packaging
The 1.6.1 release of the snap is now published to the stable risk level, here's the updated install instructions: sudo snap install xmlstarlet I will file a merge request to upstream the packaging in the near future.
Dear maintainer(s), Snaps are universal Linux packages that can be installed and run on many GNU+Linux distributions with ease. I've been following the Snapcrafters instructions and have built a working snap on the Snap Store, you may try it by running the following commands after installing snapd: # Install the snap package # sudo snap install xmlstarlet # Connect the snap to optional security confinement interfaces # ## For accessing files under `/mnt` or `/media` ## sudo snap connect xmlstarlet:removable-media...
Dear maintainer(s), Snaps are universal Linux packages that can be installed and run on many GNU+Linux distributions with ease. I've been following the Snapcrafters instructions and have built a working snap on the Snap Store, you may try it by running the following commands after installing snapd: # snap install --channel=beta xmlstarlet I'm also looking forward to working with you to make the packaging work upstream (if you're interested). You may want to check out the current packaging recipe,...
The snap is now published to the beta risk level, here's the updated install instructions: # Install the snap package # sudo snap install --channel=beta xmlstarlet # Connect the snap to optional security confinement interfaces # ## For accessing files under `/mnt` or `/media` ## sudo snap connect xmlstarlet:removable-media # Launch the application # xmlstarlet snap run xmlstarlet # If you have another existing installation xmlstarlet.xml # You can also run `xml` directly after running `sudo snap...
The snap is now published to the beta risk level, here's the updated install instructions: # Install the snap package # sudo snap install --channel=beta xmlstarlet #sudo snap install xmlstarlet # Connect the snap to optional security confinement interfaces # ## For accessing files under `/mnt` or `/media` ## sudo snap connect xmlstarlet:removable-media # Launch the application # xmlstarlet snap run xmlstarlet # If you have another existing installation xmlstarlet.xml # You can also run `xml` directly...
Dear maintainer(s), Snaps are universal Linux packages that can be installed and run on many GNU+Linux distributions with ease. I've been following the Snapcrafters instructions and have built a working snap on the Snap Store, you may try it by running the following commands after installing snapd: # snap install --channel=edge --devmode xmlstarlet I'm also looking forward to working with you to make the packaging work upstream (if you're interested). You may want to check out the current packaging...
Ah, yes, that would explain why it's missing. In this case the way to go is to try to find a fix for the "impossible" one in libxslt... Another possibility (at least theoretically) would be to rewrite the xml ed subcommand to use XSLT. But that's quite a lot of work.
Thanks, Noam, for the detailed answer! It seems to me that there is indeed XSLT support for str:replace but the XPath support was removed 5 years ago because of a bug which seemed "impossible" to fix: https://gitlab.gnome.org/GNOME/libxslt/commit/ae49d7a73b043bccb7631e7d9577bcaa0bbf8528 . Please can you confirm that this makes my code not possible to work at the moment? In this case the way to go is to try to find a fix for the "impossible" one in libxslt...
The EXSLT functions come from libxslt. The str:* functions are included: https://sourceforge.net/p/xmlstar/code/ci/master/tree/src/xml_edit.c#l465 libxslt does define str:replace so it should work: https://gitlab.gnome.org/GNOME/libxslt/blob/master/libexslt/strings.c#L850 Perhaps your version of libxslt is too old?
I would like to do something like this: xmlstarlet ed -u "/my/xpath[@entry]/@entry -x "str:replace(.,\"from\",\"to\")" But str:replace is not implemented in xmlstarlet. Unfortunately I am unsure which exslt commands are implemented, I found no information on how I get a complete list of the supported functions. I am also interested in improving the code to make this easily possible. Where to start? Thanks!
Various hangs and infinite loops found with AFL
XMLStarlet failed to properly `format` certain SVG image
Okay, sounds like it's working as intended, closing the bug.
I think this is a bug in xmlstarlet, not libxml. Specifically, these lines in xml_select.c:do_file() before the xmlReadFile call: value = xmlStrdup((const xmlChar *)"'"); value = xmlStrcat(value, (const xmlChar *)filename); value = xmlStrcat(value, (const xmlChar *)"'"); Obviously, just putting single quotes around a value which itself contains single quotes is not proper quoting.
People at libxml2 informed me that this is due to the xml:space="preserve" attribute in the SVG file, after removing the attribute xmlstarlet works as expected.
The output of xmllint --format also seems to be broken as well, so it might be a libxml issue.
XMLStarlet failed to properly `format` certain SVG image
@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?
Addtional observations: - 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"...
Addtional observations: - 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"...
Addtional observations: - 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"...