Closed flavorjones closed 1 year ago
Here's the test case:
#! /usr/bin/env ruby
# mechanize #613
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "nokogiri", path: "."
end
puts Nokogiri::VERSION_INFO
UTF8_TITLE = 'テスト'
UTF8 = <<-HTML
<title>#{UTF8_TITLE}</title>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
HTML
doc = Nokogiri::HTML4.parse(UTF8.force_encoding(Encoding::BINARY))
pp doc
pp doc.to_html
pp doc.errors
Success case is parsing the doc, failure case is raising an exception because htmlReadMemory
returns NULL
.
Git bisect says:
b167c7314497b6cb0d9a587a31874ae0d273ffaa is the first bad commit
commit b167c7314497b6cb0d9a587a31874ae0d273ffaa
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Tue Mar 14 14:42:36 2023 +0100
parser: Fix short-lived regression causing infinite loops
Fix 3eb6bf03. We really have to halt the parser, so the input buffer
gets reset.
include/private/parser.h | 2 ++
parser.c | 37 ------------------------------------
parserInternals.c | 49 +++++++++++++++++++++++++++++++++++++++---------
3 files changed, 42 insertions(+), 46 deletions(-)
Bug report filed upstream here: https://gitlab.gnome.org/GNOME/libxml2/-/issues/543
Nokogiri v1.15.x updated libxml2 to 2.11.x. The test suite is now failing on some bad-encoding-related tests:
Need to investigate.