summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-01 16:58:12 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-01 16:58:12 +0000
commit336457b2675e49b6b2708c61a5131a1cd97b6007 (patch)
tree2aedf0c05339b7feda9bdbbfedd6416b34a84544 /lib/rbot
parent8d51c4a1a5a75e8e660f85cce37efcdf993500af (diff)
More first_par fixups
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/utils/extends.rb3
-rw-r--r--lib/rbot/core/utils/utils.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb
index 95569b71..5fa24dcb 100644
--- a/lib/rbot/core/utils/extends.rb
+++ b/lib/rbot/core/utils/extends.rb
@@ -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}"
diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb
index 63cd58da..57f6a934 100644
--- a/lib/rbot/core/utils/utils.rb
+++ b/lib/rbot/core/utils/utils.rb
@@ -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)