From 61a22b729532316193612eac4f948ff11aa57f50 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 7 Jul 2008 23:14:24 +0200 Subject: httputil: don't fail when b0rked servers put the charset in the content-encoding --- lib/rbot/core/utils/httputil.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb index 9df8fc2c..ae16416d 100644 --- a/lib/rbot/core/utils/httputil.rb +++ b/lib/rbot/core/utils/httputil.rb @@ -109,7 +109,16 @@ module ::Net # TODO # debug "full inflation failed (#{e}), trying to recover as much as possible" end + when /^(?:iso-8859-\d+|windows-\d+|utf-8|utf8)$/i + # B0rked servers (Freshmeat being one of them) sometimes return the charset + # in the content-encoding; in this case we assume that the document has + # a standarc content-encoding + old_hsh = self.to_hash + self['content-type']= self['content-type']+"; charset="+method.downcase + warning "Charset vs content-encoding confusion, trying to recover: from\n#{old_hsh.pretty_inspect}to\n#{self.to_hash.pretty_inspect}" + return str else + debug self.to_hash raise "Unhandled content encoding #{method}" end end -- cgit v1.2.3