This project is archived and is in readonly mode.
capture helper assumes that text is html_safe
-
Jeff Kreeftmeijer
- State changed from new to open
- Milestone set to 3.x
- Assigned user set to Santiago Pastorino
- Tag changed from action_view, capturehelper, content_tag, escaping, helpers, xss to action_view, capturehelper, content_tag, escaping, helpers, patch, xss
- Importance changed from to Low
I've attached a patch that runs
html_escapeoncapture's output before returning. It also adds.html_safeto thetest_link_to_unlessassertion and removes anothertest_link_to_unlessI found. Don't ask me why, but there were two. Any thoughts? :) -
Santiago Pastorino
- Milestone cleared.
- Importance changed from Low to High
-
Ryan Bigg
- Tag changed from sheepskin boots, action_view, capturehelper, content_tag, escaping, helpers, patch, xss to action_view capturehelper content_tag escaping helpers patch xss
Automatic cleanup of spam.
-
Jeff Kreeftmeijer
- Tag changed from action_view capturehelper content_tag escaping helpers patch xss to action_view, capturehelper, content_tag, helpers, patch, xss
Ryan's spambot script seems to have reverted my tag changes.
-
Repository
- State changed from open to resolved
(from [bb9c58eb4aa637fa75c69c705a9918d6322ff834]) Make sure capture's output gets html_escaped [#5545 capture helper assumes that text is html_safe state:resolved]
Also remove a duplicate test_link_to_unless assertion and add .html_safe to the
remaining one.Signed-off-by: Santiago Pastorino santiago@wyeworks.com
http://github.com/rails/rails/commit/bb9c58eb4aa637fa75c69c705a9918... -
Repository
(from [5cb1dad228fb224a5661e36fe492dae700021b0f]) Make sure capture's output gets html_escaped [#5545 capture helper assumes that text is html_safe state:resolved]
Also remove a duplicate test_link_to_unless assertion and add .html_safe
to the remaining one.Signed-off-by: Santiago Pastorino santiago@wyeworks.com
http://github.com/rails/rails/commit/5cb1dad228fb224a5661e36fe492da... -
Keith Pitt
Hrm - this seems like a silly change to me.
Firstly, the documentation inside the capture helper states:
"It provides a method to capture blocks into variables through capture and a way to capture a block of markup for use in a layout through content_for."
Keyword there being "markup". If you automatically escape the content - you cant really use it for markup anymore.
Secondly, given the following helper:
def box(&block) content_tag :div, capture(&block).html_safe endWouldnt that automatically escape the html returned by capture, thus making this sort of convention impossible?
-
Wincent Colaiuta
Also not 100% sure if this is the best change, as it caused some breakage in my app where I was using it to "capture a block of markup", like Keith says.
On the other hand, at least it is more consistent than before, seeing as now both the block and non-block forms of
content_tagwill escape their content (if it is not already marked as safe).
