]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
More first_par fixups
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 1 Apr 2007 16:58:12 +0000 (16:58 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 1 Apr 2007 16:58:12 +0000 (16:58 +0000)
lib/rbot/core/utils/extends.rb
lib/rbot/core/utils/utils.rb

index 95569b71ff261b6e1bbfbb7e28273bab9eb8578c..5fa24dcbd331f44467d1fc0236c09c8f2759a21c 100644 (file)
@@ -55,6 +55,7 @@ class ::String
 
     if self.respond_to?(:http_headers) and headers = self.http_headers
       if headers['content-type'].first.match(/charset="?(\S+?)"?\s*;?/i)
+        debug "charset #{charset} set from header"
         charset = $1
       end
     end
@@ -66,10 +67,10 @@ class ::String
       when /<meta\s+http-equiv\s*=\s*"Content-Type".*charset\s*=\s*"?(\S+?)"?\s*;?/i
         charset = $1
       end
+      debug "charset #{charset} set from string"
     end
 
     if charset
-      debug "charset: #{charset}"
       return Iconv.iconv('utf-8', charset, self).join rescue self
     else
       debug "Couldn't find charset for #{self.inspect}"
index 63cd58da62cbc079c767378eeb8b486541e488c1..57f6a9345568745d0407535d9aacfe2beb931276 100644 (file)
@@ -433,7 +433,7 @@ module ::Irc
     #   * :min_spaces => Minimum number of spaces a paragraph should have
     #
     def Utils.ircify_first_html_par(xml_org, opts={})
-      xml = xml_org.gsub(/<!--.*?-->/, '').utfy_xml
+      xml = xml_org.gsub(/<!--.*?-->/m, '').gsub(/<script(?:\s+[^>]*)?>.*?<\/script>/im, "").gsub(/<style(?:\s+[^>]*)?>.*?<\/style>/im, "").utfy_xml
 
       strip = opts[:strip]
       strip = Regexp.new(/^#{Regexp.escape(strip)}/) if strip.kind_of?(String)