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.

auto_link helper incorrectly parses URIs with ampersands (&s)

State: stale
Milestone: none
Assigned to: Ryan Bigg Ryan Bigg
Importance: Low

Activity

  1. Mannie
    Mannie

    here is a patch :)

    From: http://railsforum.com/viewtopic.php?id=14293

    ActionView::Helpers::TextHelper::AUTO_LINK_RE = %r{
    (

    <a\s.*?>.*??|               # Opening <a> tag.. and any other text including html tags which might be before a url
    [^\w]|                      # or, first char before url
    ^                           # or, start of line
    

    ) (

    (?:https?://)?              # optional protocol
    (?:[-\w]+\.)+               # subdomain/domain parts
    (?:com|net|org|[a-z][a-z]|edu|gov|biz|int|mil|info|name|museum|coop|aero) # TLD
    (?::\d+)?                   # Optional port
    (?:/(?:(?:[~\w\+@%=-]|(?:[,.;:][^\s$]))+)?)*     # Path
    (?:\?[\w\+@%&=.;-]+)?       # Query String ?foo=bar
    (?:\#[\w\-]*)?              # Anchor
    

    ) (

    (?:[^\w]|$)                 # Trailing Character
    

    ) }xi

    ActionView::Helpers::TextHelper.module_eval do
    def auto_link_urls(text, href_options = {})

    extra_options = tag_options(href_options.stringify_keys) || ""
    text.gsub(ActionView::Helpers::TextHelper::AUTO_LINK_RE) do
      all, leading, url, trailing = $&, $1, $2, $3
      if leading =~ /<a\s/i # don't replace URL's that are already linked
        all
      else
        text = block_given? ? yield(url) : url
        url = 'http://' + url unless url =~ /^https?:\/\//
        %(#{leading}<a href="#{url}"#{extra_options}>#{text}</a>#{trailing})
      end
    end
    

    end end

    April 6th, 2010 @ 01:49 PM

  2. José Valim
    José Valim

    Could you please provide a patch according to the guidelines specified on the contributors guide?

    http://rails.lighthouseapp.com/projects/8994/sending-patches

    Thanks!

    April 10th, 2010 @ 12:49 PM

  3. David Trasbo
    David Trasbo
    • Assigned user set to Ryan Bigg

    This ticket can be marked as incomplete until a patch is provided.

    April 15th, 2010 @ 07:04 PM

  4. Ryan Bigg
    Ryan Bigg
    • State changed from new to incomplete

    April 15th, 2010 @ 11:00 PM

  5. Ryan Bigg
    Ryan Bigg
    • State changed from incomplete to stale
    • Importance changed from to Low

    This ticket is 6 months old. Marking as stale. If you wish for this issue to be fixed then please provide a patch.

    November 3rd, 2010 @ 04:00 AM