r-lib / xml2

Bindings to libxml2
https://xml2.r-lib.org/
Other
220 stars 82 forks source link

libxml2 2.9.13 changes recovery mode #371

Closed kcphila closed 1 year ago

kcphila commented 2 years ago

This is more of a note on html processing, in case you are not aware.

libxml2 v2.9.13, which is the newest release that gets pulled in by apt on Ubuntu 22.04, changes how the "recovery" mode works for html rendering.

Since xml2 is used by many other packages (like kableExtra and modelsummary), this may end up being a repeated issue. See the following code:

xml2::read_html("* pval < 0.05; ** pval < 0.01")

For systems that have libxml2 v.2.9.12 or before installed, the output is as expected:

{html_document}
<html>
[1] <body><p>* pval &lt; 0.05; ** pval &lt; 0.01</p></body>

For systems that have libxml2 v.2.9.13 installed, it's truncated at the first less than sign:

{html_document}
<html>
[1] <body><p>* pval </p></body>

This is a result of the upstream devs reducing recovery mode processing to avoid DDoS attacks and generally simplify processing. They also indicate in the issue linked below that this functionality is likely to continue. There's an argument to say that xml2, like libxml2, should just be concerned with processes "correct" html/xml and users should not rely on consistent recovery mode or error handling, but this also seems like a change that will affect a lot of folks doing statistics.

https://gitlab.gnome.org/GNOME/libxml2/-/issues/339

hadley commented 1 year ago

Thanks for the update; since I haven't heard any complaints about this in the 18 months since you filed an issue, it sounds like we got lucky and this doesn't affect much real world code.