From be213d7bbcaf0bd91b4c4e78f1d6a1ae3032978b Mon Sep 17 00:00:00 2001 From: "M. Hecker" Date: Tue, 2 Dec 2014 11:47:19 +0100 Subject: [url] fixes encoding error in encoding detection code, maybe closes #2 --- lib/rbot/core/utils/httputil.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/rbot') diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb index 39a47816..f7871e5b 100644 --- a/lib/rbot/core/utils/httputil.rb +++ b/lib/rbot/core/utils/httputil.rb @@ -51,6 +51,8 @@ module ::Net debug "charset #{charsets.last} added from header" end + # str might be invalid utf-8 that will crash on the pattern match: + str.encode!('UTF-8', 'UTF-8', :invalid => :replace) case str when /<\?xml\s[^>]*encoding=['"]([^\s"'>]+)["'][^>]*\?>/i charsets << $1 -- cgit v1.2.3