This project is archived and is in readonly mode.

#4681 ✓resolved
James Healy

over-escaping of content_for in 2.3.7

Reported by James Healy | May 24th, 2010 @ 05:05 PM | in 2.3.8

In 2.3.7 (and not 2.3.6) content passed from my view to the layout via a content_for block is being over-escaped. I am not using the rails_xss plugin yet.

Given a view that looks like (also available in a gist @ http://gist.github.com/411971):

<%content_for :sidebar do %>
  <h2>Sidebar</h2>
  <p><%=link_to "somewhere", "http://www.google.com/"%></p>
<% end %>

<h1>Main Heading</h1>

And a layout like:

<html>
  <head>
    <title>boo</title>
  </head>
  <body>
    <div id="sidebar">
      <%= yield :sidebar%>
    </div>
    <div id="content">
      <%= yield %>
    </div>
  </body>
</html>

I get the following output:

<html>
  <head>
    <title>boo</title>
  </head>
  <body>
    <div id="sidebar">
      
  &lt;h2&gt;Sidebar&lt;/h2&gt;

  &lt;p&gt;<a href="http://www.google.com/">somewhere</a>&lt;/p&gt;

    </div>
    <div id="content">
      

<h1>Main Heading</h1>

    </div>
  </body>

</html>

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>

Pages