auto_link escaping issues

Well, it looks like this forum is doing this correctly. Any dev's out there that can explain how they are both
escaping HTML and calling auto linking URLs?

I had the same problem. Here is a simplified version that worked for me:

    def auto_link_urls (text)
      url_regex = /

      text.gsub(url_regex) do |link|
        link = 'http://' + link if $1 == 'www.'
        link_text = block_given? ? yield(link) : link
        '<a href="' + link + '">' + link_text + '</a>'

It doesn't detect already linked URLs (I didn't need it) but it allows a
wider range of URLs (ftp://…, for example) and works with HTMLized
URLs (…?foo=1&amp;bar=2…) and some other special case original
version doesn't seem to detect (