Re: BUG #18274: Error 'invalid XML content'
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Dmitry Koval <d.koval@postgrespro.ru>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-bugs@lists.postgresql.org
Date: 2024-01-16T09:14:09Z
Lists: pgsql-bugs
On Mon, Jan 15, 2024 at 06:47:17PM +0300, Dmitry Koval wrote: > I think that's right (flag XML_PARSE_HUGE shouldn't cause any problems). > My main doubts are related to the replacement of the > xmlParseBalancedChunkMemory() function (that haven't argument for pass > XML_PARSE_HUGE flag) with xmlNewNode() + xmlParseInNodeContext() functions > (create a fake node and pass the XML_PARSE_HUGE flag to > xmlParseInNodeContext function). > > I'm not sure if this replacement is 100% equivalent (although simple tests > work the same). Hmm, it looks like this is actually equivalent in terms of parsing a well-balanced chunk. This was suggested in the upstream ticket you have opened and I find that pretty cool, reusing the trick of a fake root node to use the other API. Now, there are two things that we'd better do here: - Document in a comment why a fake root node is necessary (aka the current routines don't give enough control over the limits you'd like to enforce). - The top comment of xml_parse() still mentions xmlParseBalancedChunkMemory() as an effect of 483bdb2afec9, so this needs to be updated. The switch xmlParseMemory() -> xmlReadMemory() is recommended by the upstream docs and the former is deprecated: https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParseMemory Also, it may be worth double-checking if there are other things marked as deprecated in the upstream doc, and switch to "newer" things. It seems like anything discussed here should only be done on HEAD. I suspect that the buildfarm may get bumpy on that, but let's see. -- Michael
Commits
-
xml2: Replace deprecated routines with recommended ones
- 4b0e5d601291 12.19 landed
- bb418aeee270 13.15 landed
- 6fa5e67e832b 14.12 landed
- 689ba4f1c406 15.7 landed
- 7c93f31dee5f 16.3 landed
- 65c5864d7fac 17.0 landed
-
Revert "Add support for parsing of large XML data (>= 10MB)"
- f2743a7d70e7 17.0 landed
-
Add support for parsing of large XML data (>= 10MB)
- 2197d06224a1 17.0 landed