Re:Parsing XML at the Speed of Light (2012)
by maskros on Tuesday July 19, 2022 @05:49AM
(#32149429)
libxml2 can be massive overkill if you just want to parse XML data. Unless you need schema validation and namespaces and all that jazz, you can parse XML in C with a simple state machine of ~200 lines. Add another 200 to build a DOM-like structure.
https://github.com/ccxvii/snippets/blob/master/xml.c#L326
Or in lua with ~200 lines altogether:
Re:Parsing XML at the Speed of Light (2012)
by johannes1234321 on Tuesday July 19, 2022 @05:59AM
(#32149489)
Yes, libxml2 is a widespread, thus mostly unproblematic choice. However pulling in a third party is not only about license.
With a thirdparty library you have to follow security updates (also to parts you don't need), may have build issues on some platforms you want to support (something embedded?) and so on.
If you don't need XML, but just a few xml-like tags a custom parser can be done quickly. But yes then you get to the NHI problems and what if your assumptions about XML subset were wrong ...
Personally I would lean on an XML lib (maybe libyml2, maybe qxml, maybe windows API, ... depending on context) as XML is complex, but generally adding libraries introduce their costs.
Re:Parsing XML at the Speed of Light (2012)
by sgtnoodle on Tuesday July 19, 2022 @07:32PM
(#32159353)
I didn't need to parse any XML file, but rather a specific XML file. It was inside an ITAR restricted codebase, and lawyers are conservative about open source in that context. In terms of security, it wasn't internet facing, and was written to the same standard as safety critical embedded software.
Re:Parsing XML at the Speed of Light (2012)
by plugin-baby on Tuesday July 19, 2022 @05:40AM
(#32149387)
Do you have other objections beyond the wasted effort of re-writing the wheel?
Re:Parsing XML at the Speed of Light (2012)
by planede on Tuesday July 19, 2022 @09:12AM
(#32150956)
I think a lot of people trivialize XML parsing here. Given how many dedicated libraries screwed up JSON parsing, which should be much easier, I have very little faith in people getting XML parsing right in-house.
Re:Parsing XML at the Speed of Light (2012)
by TedDoesntTalk on Tuesday July 19, 2022 @10:23AM
(#32151922)
There are many security vulnerability vectors in xml parsing. A lot (but not all) have to do with DTD entity replacement, calls to remote URLs for schemas, and the like, buffer overflows (values too large).
How? I would violently object for implementing an in-house XML parser as opposed to just finding a way to include libxml2. It's under the MIT license, so I doubt that was an issue.