Skip to content

Commit

Permalink
test: accept "UTF-8" as an encoding alias for "UTF8"
Browse files Browse the repository at this point in the history
As of libxml 2.12.0, the `page.encoding` value inspected by this test
is dependent on how libiconv is built (specifically: which aliases are
supported).

- if alias "UTF8" is defined, then the page encoding will be "UTF-8"
- if alias "UTF8" is not defined, then the page encoding will be "UTF8"

The modified test started failing on Windows and MacOS (where Nokogiri
compiles libiconv and statically links it into the
native (precompiled) gem) but still passed on Linux (where libc
dynamically provides libiconv symbols).
  • Loading branch information
flavorjones committed Dec 29, 2023
1 parent 245cc78 commit 46482f1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/test_mechanize_http_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1309,8 +1309,13 @@ def test_response_parse_content_type_encoding_broken_utf_8
page = @agent.response_parse @res, body, @uri

assert_instance_of Mechanize::Page, page
assert_equal 'UTF8', page.encoding
assert_equal 'UTF8', page.parser.encoding

# as of libxml 2.12.0, the result is dependent on how libiconv is built (which aliases are supported)
# if the alias "UTF8" is defined, then the result will be "UTF-8".
# if the alias "UTF8" is not defined, then the result will be "UTF8".
# note that this alias may be defined by Nokogiri itself in its EncodingHandler class.
assert_includes ["UTF8", "UTF-8"], page.encoding
assert_includes ["UTF8", "UTF-8"], page.parser.encoding
end

def test_response_parse_content_type_encoding_garbage
Expand Down

0 comments on commit 46482f1

Please sign in to comment.