This project is archived and is in readonly mode.

#4570 ✓stale
David

Autolink hyperlinks links that are already hyperlinked

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

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

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg May 13th, 2010 @ 11:56 PM

    • Tag set to bugmash
    • State changed from “new” to “incomplete”

    Please provide a test case and patch for this issue.

  • Christopher Redinger

    Christopher Redinger May 14th, 2010 @ 06:46 PM

    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

  • Christopher Redinger

    Christopher Redinger May 14th, 2010 @ 06:49 PM

    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>"
    
  • Rohit Arondekar

    Rohit Arondekar June 19th, 2010 @ 11:49 AM

    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
    
  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:36 PM

    • 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.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:36 PM

    • State changed from “open” to “stale”

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>

Tags

Pages