diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-04-08 21:11:31 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-04-08 21:11:31 +0000 |
commit | c16c0bb386c322c580aa70b4e6bb20252a235f9e (patch) | |
tree | 35579bd106952eb15047dd649b8b31073cbbe630 | |
parent | 90a205831d3b120360df5dcb5f61136b0ed31dd0 (diff) |
HTML IRCification: don't modify the receiver; provide an ircify_html! method to modify in place
-rw-r--r-- | lib/rbot/core/utils/extends.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb index b812a676..950ad678 100644 --- a/lib/rbot/core/utils/extends.rb +++ b/lib/rbot/core/utils/extends.rb @@ -56,7 +56,7 @@ class ::String # stripped off and some of it converted to IRC formatting # def ircify_html - txt = self + txt = self.dup # remove scripts txt.gsub!(/<script(?:\s+[^>]*)?>.*?<\/script>/im, "") @@ -108,6 +108,14 @@ class ::String return txt.strip end + # As above, but modify the receiver + # + def ircify_html! + old_hash = self.hash + replace self.ircify_html + return self unless self.hash == old_hash + end + # This method will strip all HTML crud from the receiver # def riphtml |