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.

link_to with block failing on 2.3.8 with rails_xss

#4694

I'm getting an

"Undefined method stringify_keys' for "/foo":ActiveSupport::SafeBuffer"

when I try to pass a block to the link_to helper with rails 2.3.8 and the rails_xss plugin installed.

<% link_to("foo", foo_path) do %>
  <span class="bar">blah</span>
<% end %>

calling link_to without the block works fine.

<%= link_to("foo", foo_path) %>

Reported by ipster · May 25th, 2010 @ 07:56 PM

State: invalid
Milestone: 2.3.8
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Santiago Pastorino
    Santiago Pastorino
    • Milestone set to 2.3.8
    • State changed from new to open
    • Assigned user set to Jeremy Kemper

    Confirmed bug, a missing require.
    This method is passing on tests because test/template/url_helper_test.rb loads action_controller, which loads active_support and then we have the stringify on tests loaded.

    May 25th, 2010 @ 09:05 PM

  2. Santiago Pastorino
    Santiago Pastorino

    The test i've added is not a test that makes the suite fail is only one more test for link_to with a block.
    I think the abstract_test.rb file should be splitted.

    May 25th, 2010 @ 09:08 PM

  3. Santiago Pastorino
    Santiago Pastorino

    Attaching a patch without this test because there's another similar

    May 25th, 2010 @ 09:10 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • Tag changed from 2.3.8, link_to, rails_xss to 2.3.8, link_to, patch, rails_xss
    • State changed from open to invalid

    Sorry i got confused is not a bug.

    You have to do ...

    <% link_to(foo_path) do %>
    blah <% end %>

    You're passing a first string parameters that shouldn't be there.

    http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.htm...

    Also there's a missing require on this class patch attached here.

    May 25th, 2010 @ 09:49 PM

  5. Santiago Pastorino
    Santiago Pastorino

    Sorry for the formatting

    You should do ...

    <% link_to(foo_path) do %>
      THINGS ...
    <% end %>
    

    May 25th, 2010 @ 09:51 PM

  6. Neeraj Singh
    Neeraj Singh

    Not a bug. As per API you should do

     <% link_to(@profile) do %>
         <strong><%= @profile.name %></strong> -- <span>Check it out!!</span>
     <% end %>
    

    May 25th, 2010 @ 09:56 PM

  7. Neeraj Singh
    Neeraj Singh

    Sorry did not see that super fast Santiago had already updated the ticket. I should have refreshed my page.

    May 25th, 2010 @ 09:57 PM

  8. ipster
    ipster

    Oops - thanks! Sorry for the false alarm

    May 25th, 2010 @ 10:43 PM