Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Autolink hyperlinks links that are already hyperlinked

#4570

Hi,

I have found that urls that have a tag (e.g. ) after an tag but before the link's text have an excess tag wrapped around links that are already hyper-linked.

Here's my test case:

http://www.yahoo.com

Here's some example code:

C:>irb
irb(main):001:0> require 'action_view'
=> true irb(main):002:0> include ActionView::Helpers::TextHelper
=> Object irb(main):003:0> include ERB::Util
=> Object irb(main):004:0> include ActionView::Helpers::TagHelper
=> Object irb(main):005:0> url = '<a href="http://www.yahoo.com" ><span id="test">http://www.yahoo.com </span ></a>'
=> "<a href="http://www.yahoo.com" ><span id="test"> http://www.yahoo.com </span></a>" irb(main):006:0> auto_link(url)
=> "<a href="http://www.yahoo.com" ><span id="test"><a href="http://www.yahoo.com" >http://www.yahoo.com </a></span></a>"

irb(main):007:0> exit

Reported by David · May 10th, 2010 @ 05:28 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg
    • Tag set to bugmash
    • State changed from new to incomplete

    Please provide a test case and patch for this issue.

    May 13th, 2010 @ 11:56 PM

  2. Christopher Redinger
    Christopher Redinger

    Did some experimenting:

    include ActionView::Helpers::TextHelper
    include ERB::Util
    include ActionView::Helpers::TagHelper
    url = 'foo'
    => "
    => "
    => "
    => "

    My thoughts on the subject, the way to fix auto_link to handle this case would be to change it to be able to parse the HTML spec. It seems like a significant amount of work to enable this behavior

    May 14th, 2010 @ 06:46 PM

  3. Christopher Redinger
    Christopher Redinger

    And the formatted version...

    require 'action_view'
    include ActionView::Helpers::TextHelper
    include ERB::Util
    include ActionView::Helpers::TagHelper
    url = '<a href="http://www.yahoo.com" >foo</a>'
     => "<a href=\"http://www.yahoo.com\" >foo</a>"
    auto_link(url)
     => "<a href=\"http://www.yahoo.com\" >foo</a>" 
    url = '<a href="http://www.yahoo.com" >http://www.google.com</a>'
     => "<a href=\"http://www.yahoo.com\" >http://www.google.com</a>" 
    auto_link(url)
     => "<a href=\"http://www.yahoo.com\" ><a href=\"http://www.google.com\">http://www.google.com</a></a>"
    

    May 14th, 2010 @ 06:49 PM

  4. Rohit Arondekar
    Rohit Arondekar

    This is also how RDiscount(markdown parser) behaves. Not saying it's the perfect argument to say this is not a bug but if it requires a lot of work, maybe it's best not to pass html'ized links to auto_link.

    RDiscount behaviour:

    ruby-1.9.2-head > puts RDiscount.new('<a href="http://google.com">http://google.com</a>', :autolink).to_html
    <p><a href="http://google.com"><a href="http://google.com">http://google.com</a></a></p>
     => nil
    

    June 19th, 2010 @ 11:49 AM

  5. Santiago Pastorino
    Santiago Pastorino
    • State changed from incomplete to open
    • Importance changed from to Low

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:36 PM

  6. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:36 PM