1.15.0 / 2023-05-15
Notes
Ability to opt into system malloc
and free
Since 2009, Nokogiri has configured libxml2 to use ruby_xmalloc
et al for memory management. This has provided benefits for memory management, but comes with a performance penalty.
Users can now opt into using system malloc
for libxml2 memory management by setting an environment variable:
# "default" here means "libxml2's default" which is system malloc
NOKOGIRI_LIBXML_MEMORY_MANAGEMENT=default
Benchmarks show that this setting will significantly improve performance, but be aware that the tradeoff may involve poorer memory management including bloated heap sizes and/or OOM conditions.
You can read more about this in the decision record at adr/2023-04-libxml-memory-management.md
.
Dependencies
- [CRuby] Vendored libxml2 is updated to v2.11.3 from v2.10.4. For details please see:
- [CRuby] Vendored libxslt is updated to v1.1.38 from v1.1.37. For details please see:
Added
Encoding
objects may now be passed to serialization methods like#to_xml
,#to_html
,#serialize
, and#write_to
to specify the output encoding. Previously only encoding names (strings) were accepted. [#2774, #2798] (Thanks, @ellaklara!)- [CRuby] Users may opt into using system
malloc
for libxml2 memory management. For more detail, see note above oradr/2023-04-libxml-memory-management.md
.
Changed
- [CRuby]
Schema.from_document
now makes a defensive copy of the document if it has blank text nodes with Ruby objects instantiated for them. This prevents unsafe behavior in libxml2 from causing a segfault. There is a small performance cost, but we think this has the virtue of being "what the user meant" since modifying the original is surprising behavior for most users. Previously this was addressed in v1.10.9 by raising an exception.
Fixed
- [CRuby]
XSLT.transform
now makes a defensive copy of the document if it has blank text nodes with Ruby objects instantiated for them and the template usesxsl:strip-spaces
. This prevents unsafe behavior in libxslt from causing a segfault. There is a small performance cost, but we think this has the virtue of being "what the user meant" since modifying the original is surprising behavior for most users. Previously this would allow unsafe memory access and potentially segfault. [#2800]
Improved
Nokogiri::XML::Node::SaveOptions#inspect
now shows the names of the options set in the bitmask, similar toParseOptions
. [#2767]#inspect
and pretty-printing are improved forAttributeDecl
,ElementContent
,ElementDecl
, andEntityDecl
.- [CRuby] The C extension now uses Ruby's TypedData API for managing all the libxml2 structs. Write barriers may improve GC performance in some extreme cases. [#2808] (Thanks, @etiennebarrie and @byroot!)
- [CRuby]
ObjectSpace.memsize_of
reports a pretty good guess of memory usage when called onNokogiri::XML::Document
objects. [#2807] (Thanks, @etiennebarrie and @byroot!) - [CRuby] Users installing the "ruby" platform gem and compiling libxml2 and libxslt from source will now be using a modern
config.guess
andconfig.sub
that supports new architectures likeloongarch64
. [#2831] (Thanks, @zhangwenlong8911!) - [CRuby] HTML5 parser:
- adjusts the specified attributes, adding
xlink:arcrole
and removingxml:base
[#2841, #2842] - allows
<hr>
in<select>
[whatwg/html#3410, whatwg/html#9124]
- adjusts the specified attributes, adding
- [JRuby]
Node#first_element_child
now returnsnil
if there are only non-element children. Previously a null pointer exception was raised. [#2808, #2844] - Documentation for
Nokogiri::XSLT
now has usage examples including custom function handlers.
Deprecated
- Passing a
Nokogiri::XML::Node
as the first parameter toCDATA.new
is deprecated and will generate a warning. This parameter should be a kind ofNokogiri::XML::Document
. This will become an error in a future version of Nokogiri. - Passing a
Nokogiri::XML::Node
as the first parameter toSchema.from_document
is deprecated and will generate a warning. This parameter should be a kind ofNokogiri::XML::Document
. This will become an error in a future version of Nokogiri. - Passing a
Nokogiri::XML::Node
as the second parameter toText.new
is deprecated and will generate a warning. This parameter should be a kind ofNokogiri::XML::Document
. This will become an error in a future version of Nokogiri. - [CRuby] Calling a custom XPath function without the
nokogiri
namespace is deprecated and will generate a warning. Support for non-namespaced functions will be removed in a future version of Nokogiri. (Note that JRuby has never supported non-namespaced custom XPath functions.)
Thank you!
The following people and organizations were kind enough to sponsor @flavorjones or the Nokogiri project during the development of v1.15.0:
- Götz Görisch (@GoetzGoerisch)
- Airbnb (@airbnb)
- Kyohei Nanba (@kyo-nanba)
- Maxime Gauthier (@biximilien)
- @renuo
- @dbootyfvrt
- YOSHIDA Katsuhiko (@kyoshidajp)
- Homebrew (@Homebrew)
- Hiroshi SHIBATA (@hsbt)
- PuLLi (@the-pulli)
- SiteLog GmbH (@sitelog-gmbh)
- @zzak
- Evil Martians (@evilmartians)
- Ajaya Agrawalla (@ajaya)
- Modern Treasury (@Modern-Treasury)
- Danilo Lessa Bernardineli (@danlessa)
We'd also like to thank @github who donate a ton of compute time for our CI pipelines!
sha256 checksums:
7dbb717c6abc6b99baa4a4e1586a6de5332513f72a8b3568a69836268c2e1f86 nokogiri-1.15.0-aarch64-linux.gem
a60c373d86a9a181f9ace78793c4a91ab8fa971af3cce93e9fdf022cd808fe41 nokogiri-1.15.0-arm-linux.gem
41d312b2d4aa6b6750c2431a25c1bf25fb567bc1e0a750cf55dd02354967724b nokogiri-1.15.0-arm64-darwin.gem
51cc8d4d98473d00c0ee18266d146677161b6dd16f8c89cc637db91d47b87c63 nokogiri-1.15.0-java.gem
1b2d92e240d12ac0a27cb0618f52af6c405831fd339a45aaab265cecda1dc6ab nokogiri-1.15.0-x64-mingw-ucrt.gem
497840b3ed9037095fbdd1bf6f7c63d23efab5bcbb03b89d94a6ac8bcab3eda5 nokogiri-1.15.0-x64-mingw32.gem
5c26427f3cf28d8c1e43f7a7bc58e50298461c7bed5179456b122eefc2b2c5cb nokogiri-1.15.0-x86-linux.gem
cbf93df1c257693dfe804c01252415ca7cb9d2452d6cebddf7a35a5dbeb3ea12 nokogiri-1.15.0-x86-mingw32.gem
ca6cd6ed08e736063539c4aa7454391dfa4153908342e3d873f5bd9218d6f644 nokogiri-1.15.0-x86_64-darwin.gem
4b28e9151e884c10794e0acf4a6f49db933eee3cd90b20aab952ee0102a03b0c nokogiri-1.15.0-x86_64-linux.gem
0ca8ea2149bdaaae8db39f11971af86c83923ec58b72c519d498ec44e1dfe97f nokogiri-1.15.0.gem