diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-04-01 17:15:50 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-04-01 17:15:50 +0000 |
commit | 54880f0f16d148cc0433492d46ff96104a904a22 (patch) | |
tree | 6777f70fd57ec09650dfbad8460e2c6845f88639 /lib/rbot | |
parent | 336457b2675e49b6b2708c61a5131a1cd97b6007 (diff) |
fix charset detection
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/core/utils/extends.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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 /<meta\s+http-equiv\s*=\s*"Content-Type".*charset\s*=\s*"?(\S+?)"?\s*;?/i + when /<meta\s+http-equiv\s*=\s*["']?Content-Type["']?.*charset\s*=\s*(\S+?)(?:;|["']|\s).*>/i charset = $1 end debug "charset #{charset} set from string" |