From 2905d1791ccbe3a00669971d7d5e690643827751 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 23 Aug 2007 07:27:32 +0000 Subject: url plugin: escape stuff before extracting urls --- data/rbot/plugins/url.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index 373d5a87..77793b93 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -6,6 +6,7 @@ end class UrlPlugin < Plugin TITLE_RE = /<\s*?title\s*?>(.+?)<\s*?\/title\s*?>/im LINK_INFO = "[Link Info]" + OUR_UNSAFE = Regexp.new("[^#{URI::PATTERN::UNRESERVED}#{URI::PATTERN::RESERVED}%# ]", false, 'N') BotConfig.register BotConfigIntegerValue.new('url.max_urls', :default => 100, :validate => Proc.new{|v| v > 0}, @@ -131,7 +132,9 @@ class UrlPlugin < Plugin def listen(m) return unless m.kind_of?(PrivMessage) return if m.address? - urls = URI.extract(m.message) + + escaped = URI.escape(m.message, OUR_UNSAFE) + urls = URI.extract(escaped) return if urls.empty? debug "found urls #{urls.inspect}" list = @registry[m.target] -- cgit v1.2.3