This project is archived and is in readonly mode.

#3591 ✓resolved
Kostas K.

auto_link should not create a link inside a link which has the rel attribute

Reported by Kostas K. | December 17th, 2009 @ 09:44 AM

auto_link gets confused when the a tag has something more than the href attribute and relinks inner html of the link

>> a = "<a href=\"http://google.gr\" rel=\"nofollow\">http://google.gr</a>"
=> "<a href=\"http://google.gr\" rel=\"nofollow\">http://google.gr</a>"
>> auto_link(a)
=> "<a href=\"http://google.gr\" rel=\"nofollow\"><a href=\"http://google.gr\">http://google.gr</a></a>"
>> auto_link(a.gsub(/\srel\="nofollow"/, ""))
=> "<a href=\"http://google.gr\">http://google.gr</a>"

sadly enough, I have fixed it locally but can't manage to submit a patch since I can't run the tests (and don't really have much time right now, might try to build a patch next week or something) but here is what seems like it helps a bit:

diff text_helper.rb  text_helper_modified.rb 
550c550
<             if left =~ /<[^>]+$/ && right =~ /^[^>]*>/
---
>             if (left =~ /<[^>]+$/ && right =~ /^[^>]*>/) || (left =~ /<a\b[^>]+>$/i && right =~ /^<\/a>/i)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages