]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/utils/httputil.rb
[url] fixes encoding error in encoding detection code, maybe closes #2
[user/henk/code/ruby/rbot.git] / lib / rbot / core / utils / httputil.rb
index 39a4781662fe4d03512839413b32e04160875129..f7871e5be7dfb34d28a7d84a2c669c6efcff4a5e 100644 (file)
@@ -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