]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/utils/utils.rb
utils: don't hang when getting first par with nonexistant uri-fragment
[user/henk/code/ruby/rbot.git] / lib / rbot / core / utils / utils.rb
index 7b1ff7f15b81b79b873fce8753cf1b19f1421644..ce5cdea4917cabafa55f88a5b8896accf1054898 100644 (file)
@@ -618,11 +618,18 @@ module ::Irc
     # uri_fragment:: the URI fragment of the original request
     #
     def Utils.get_string_html_info(text, opts={})
+      debug "getting string html info"
       txt = text.dup
       title = txt.ircify_html_title
+      debug opts
       if frag = opts[:uri_fragment] and not frag.empty?
-        fragreg = /.*?<a\s+[^>]*name=["']?#{frag}["']?.*?>/im
-        txt.sub!(fragreg,'')
+        fragreg = /<a\s+[^>]*name=["']?#{frag}["']?[^>]*>/im
+        debug fragreg
+        debug txt
+        if txt.match(fragreg)
+          # grab the post-match
+          txt = $'
+        end
       end
       c_opts = opts.dup
       c_opts[:strip] ||= title