Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concat calls in plugins/gems are escaped #6

Open
dpickett opened this issue Dec 7, 2009 · 3 comments
Open

Concat calls in plugins/gems are escaped #6

dpickett opened this issue Dec 7, 2009 · 3 comments

Comments

@dpickett
Copy link

dpickett commented Dec 7, 2009

IE

in binarylogic/searchlogic (line 69 of rails_helpers.rb):

concat(content_tag("div", hidden_field_tag("#{args.first}[order]", search_obj.order)) + "\n")

and in dpickett/tab_menu (line 15 of view_helpers.rb):

concat("<ul #{html_option_strings.join}>")
@NZKoz
Copy link
Owner

NZKoz commented Dec 8, 2009

The first case is an interesting one, it's not 'html_safe?' because there's the + "\n" in there, another option would be to make String#+ escape it's other operands instead of just marking the result as unsafe... Not sure what the right fix is there, do you have any thoughts?

That second case is expected behaviour, you should be able to use content_tag or tag to build those up and have it work without issue.

@dpickett
Copy link
Author

dpickett commented Dec 8, 2009

ok, that makes sense - I patched tab_menu

I wouldn't classify \n or \r as un-safe - should the check call "strip" on the string before checking?

@NZKoz
Copy link
Owner

NZKoz commented Dec 8, 2009

yeah, \n isn't 'unsafe' in the sense that it's an attack vector, but with the new xss code everything is considered unsafe unless marked safe. So the options when adding an unsafe string to a safe one are:

  1. new_string = (self + other).unsafe!
  2. new_string = (self + escape(other)).safe!

Currently we do 1, and my gut says that's the right approach, though this single trailing newline version is pretty annoying....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants