This project is archived and is in readonly mode.
Content_tag does not escape its input!
-
Bruno Michel
- Tag changed from 3.0pre, xss to 3.0pre, patch, xss
I really think that
content_tagshould be public, so I've patched it. Fixing the failing tests was not that hard. So here's the patch. -
Santiago Pastorino
Why did you remove to_s from select_html << select_options_as_html.to_s ?
-
Bruno Michel
I remove it because it's useless.
select_options_as_htmlis an argument passed tobuild_select.build_selectis called two times in the whole Rails codebase, and for those two times,select_options_as_htmlis already a string. Moreover, considering the means ofbuild_select, I can't see why you someone should want to give it anything else than a String (or a SafeBuffer, of course). So, I remove it as I think it's a ugly artifact.But, if it's a problem, I can redo the patch with the
to_s.Thanks for your review :-)
-
Santiago Pastorino
Yes, you're right and is a privare method.
So +1 for the patch.
I have a complementary patch for this one so i'll talk to yehuda to apply both. -
Santiago Pastorino
Hey Michael the last thing, I'd do that to your patch
-
content = content.html_safe unless escape -
content = html_escape(content) if escape -
content_tag :textarea, content, { "name" => name, "id" => sanitize_to_id(name) }.update(options) -
content_tag :textarea, content.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)
Are you agree? I think it's cleaner.
-
-
Santiago Pastorino
change ... content = content.html_safe unless escape to content = html_escape(content) if escape (that was the original line)
and change ... content_tag :textarea, content, { "name" => name, "id" => sanitize_to_id(name) }.update(options) to content_tag :textarea, content.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options) -
Bruno Michel
I'm OK with this change.
By the way, my firstname is Bruno and my lastname Michel, not Michael ;-)
-
Santiago Pastorino
Sorry Bruno, Yehuda is about to apply it, great work.
-
Prem Sichanugrist (sikachu)
- State changed from new to resolved
-
thedarkone
Shouldn't this also go into the current
2-3-stable? -
Santiago Pastorino
thedarkone: The current 2-3-stable has all the necessary things regarding html_safe, or at least the known ones.
If you use http://github.com/rails/rails_xss with a 2-3-stable application you have all the protections against xss. -
thedarkone
Yes, you are right indeed. My bad, I missed your yesterday's commit. Thanks.
