This project is archived and is in readonly mode.
There is no way to have an unescaped html in a link title
Reported by Sam Saffron | January 18th, 2010 @ 03:20 AM
Sometimes I use link_to to link an image.
In rails 3 the name is always escaped:
"<a #{href_attr}#{tag_options}>#{ERB::Util.h(name || url)}</a>".html_safe!
Can you add an option to link_to that matches the option on url_for so it accepts :escape like url_for does.
Comments and changes to this ticket
-
Prem Sichanugrist (sikachu) January 18th, 2010 @ 07:24 AM
If you're going to link to image, use
image_tag
helper, or just mark your<img>
tag hashtml_safe!
link_to image_tag('foo.png'), '/go/to/foo' link_to '<img src="foo.png" />'.html_safe!, '/go/to/foo'
All string that isn't marked as
html_safe
will always be escaped in Rails 3. -
Sam Saffron January 18th, 2010 @ 07:38 AM
Ok makes sense however there is an inconsistency with the implementation of url_for. Does it need that escape logic there ?
-
Prem Sichanugrist (sikachu) January 18th, 2010 @ 07:59 AM
I think there's a use case for escape logic there. One of the example would be if you're going to include the url generated from
url_for
as a parameter in GET request, so it would escape&
in the value. -
José Valim January 18th, 2010 @ 08:24 AM
- State changed from new to invalid
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>