From c16c0bb386c322c580aa70b4e6bb20252a235f9e Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 8 Apr 2007 21:11:31 +0000 Subject: HTML IRCification: don't modify the receiver; provide an ircify_html! method to modify in place --- lib/rbot/core/utils/extends.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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>/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 -- cgit v1.2.3