Skip to content

Commit 9c512ef

Browse files
abetomokou
andauthored
Fix garbled text in Wiki (#177)
GitHub fixes GH-176 The default value for encoding in `Nokogiri::HTML::SAX::Parser.new` has changed since Nokogiri 1.17.0. * 1.16.8: https://github.com/sparklemotion/nokogiri/blob/v1.16.8/lib/nokogiri/xml/sax/parser.rb#L72 * `def initialize(doc = Nokogiri::XML::SAX::Document.new, encoding = "UTF-8")` * 1.17.0: https://github.com/sparklemotion/nokogiri/blob/v1.17.0/lib/nokogiri/xml/sax/parser.rb#L95 * `def initialize(doc = Nokogiri::XML::SAX::Document.new, encoding = nil)` * sparklemotion/nokogiri@35596e7#diff-116e772eb2e47bb59e0798183732d07ef3312e480c764a6dc34b09f743a73f8c This causes the encoding to be unspecified, resulting in garbled text. Therefore, we changed it to specify `html.encoding`. --------- Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
1 parent 0de387e commit 9c512ef

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/full_text_search/markup_parser.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def parse(object, attribute, options={})
1818
return ["", []] unless html.present?
1919

2020
document = Document.new
21-
parser = Nokogiri::HTML::SAX::Parser.new(document)
21+
# We need .to_s for old Nokogiri. We can remove the .to_s after we drop support for Redmine < 6.0.
22+
# Redmine 6.0 requires Nokogiri 1.18.3 or later.
23+
parser = Nokogiri::HTML::SAX::Parser.new(document, html.encoding.to_s)
2224
parser.parse(html)
2325
[document.text.strip, document.tag_ids]
2426
end

0 commit comments

Comments
 (0)