From: Giuseppe Bilotta Date: Sun, 1 Apr 2007 17:15:50 +0000 (+0000) Subject: fix charset detection X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=54880f0f16d148cc0433492d46ff96104a904a22;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git fix charset detection --- diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb index 5fa24dcb..fa2dff95 100644 --- a/lib/rbot/core/utils/extends.rb +++ b/lib/rbot/core/utils/extends.rb @@ -54,7 +54,7 @@ class ::String charset = nil if self.respond_to?(:http_headers) and headers = self.http_headers - if headers['content-type'].first.match(/charset="?(\S+?)"?\s*;?/i) + if headers['content-type'].first.match(/charset=(\S+?)\s*(?:;|\Z)/i) debug "charset #{charset} set from header" charset = $1 end @@ -64,7 +64,7 @@ class ::String case self when /<\?xml.*encoding="(\S+)".*\?>/i charset = $1 - when //i charset = $1 end debug "charset #{charset} set from string"