summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorM. Hecker <apoc@sixserv.org>2014-12-02 11:47:19 +0100
committerM. Hecker <apoc@sixserv.org>2014-12-02 11:47:19 +0100
commitbe213d7bbcaf0bd91b4c4e78f1d6a1ae3032978b (patch)
treef9e23ac44bff2acfc0e391ef672ca7c18efde993 /lib/rbot
parent633fdf34ed152f06b123e7b3167177bf385f49bb (diff)
[url] fixes encoding error in encoding detection code, maybe closes #2
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/utils/httputil.rb2
1 files changed, 2 insertions, 0 deletions
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