foundation: fix mojibake in artist commentaries.

Fix certain artist commentaries for foundation.app containing scrambled
characters. Apparently caused by the Nokogiri HTML5 parser not handling
UTF-8 input correctly when the encoding isn't explicitly set to UTF-8.
This commit is contained in:
evazion
2021-11-15 04:46:52 -06:00
parent 76ecf6d30b
commit b561ca49f2
2 changed files with 26 additions and 1 deletions

View File

@@ -5,7 +5,8 @@ module Danbooru
HTTP::MimeType.register_alias "text/html", :html
def decode(str)
Nokogiri::HTML5(str, max_tree_depth: -1)
# XXX technically should use the charset from the http headers.
Nokogiri::HTML5.parse(str.force_encoding("utf-8"), max_tree_depth: -1)
end
end
end