Skip to content

Commit 461a96e

Browse files
committed
fix: Reader#read sets @encoding if it is unset
This allows Reader#encoding to remain unchanged while the libxml2 implementation of encoding reporting has changed in v2.12.6.
1 parent 801f978 commit 461a96e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ Nokogiri follows [Semantic Versioning](https://semver.org/), please see the [REA
1111
* [CRuby] Vendored libxml2 is updated to [v2.12.6](https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.12.6) from v2.12.5. (@flavorjones)
1212

1313

14+
### Changed
15+
16+
* [CRuby] `XML::Reader` sets the `@encoding` instance variable during reading if it is not passed into the initializer. Previously, it would remain `nil`. The behavior of `Reader#encoding` has not changed. This works around changes to how libxml2 reports the encoding used in v2.12.6.
17+
18+
1419
## v1.16.2 / 2024-02-04
1520

1621
### Security

ext/nokogiri/xml_reader.c

+1
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ read_more(VALUE self)
537537
if (RTEST(constructor_encoding)) {
538538
c_document->encoding = xmlStrdup(BAD_CAST StringValueCStr(constructor_encoding));
539539
} else {
540+
rb_iv_set(self, "@encoding", NOKOGIRI_STR_NEW2("UTF-8"));
540541
c_document->encoding = xmlStrdup(BAD_CAST "UTF-8");
541542
}
542543
}

0 commit comments

Comments
 (0)