Skip to content

Commit

Permalink
fix: Reader#read sets @encoding if it is unset
Browse files Browse the repository at this point in the history
This allows Reader#encoding to remain unchanged while the libxml2
implementation of encoding reporting has changed in v2.12.6.
  • Loading branch information
flavorjones committed Mar 15, 2024
1 parent 801f978 commit 461a96e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Nokogiri follows [Semantic Versioning](https://semver.org/), please see the [REA
* [CRuby] Vendored libxml2 is updated to [v2.12.6](https://gitlab.gnome.org/GNOME/libxml2/-/releases/v2.12.6) from v2.12.5. (@flavorjones)


### Changed

* [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.


## v1.16.2 / 2024-02-04

### Security
Expand Down
1 change: 1 addition & 0 deletions ext/nokogiri/xml_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ read_more(VALUE self)
if (RTEST(constructor_encoding)) {
c_document->encoding = xmlStrdup(BAD_CAST StringValueCStr(constructor_encoding));
} else {
rb_iv_set(self, "@encoding", NOKOGIRI_STR_NEW2("UTF-8"));
c_document->encoding = xmlStrdup(BAD_CAST "UTF-8");
}
}
Expand Down

0 comments on commit 461a96e

Please sign in to comment.