forked from NZKoz/rails_xss
-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
The latest patch breaks $-variable binding in the callback to gsub on SafeStrings:
before:
"a".html_safe.gsub(/(a)/) { $1 } == "a"
after:
"a".html_safe.gsub(/(a)/) { $1 } == ""
We noticed this because CGI::escape uses this behaviour, so if you pass a safe buffer as a URL argument to a url helper, you will get an exception, a snippet from our codebase:
link_to "Please log in", login_url(:return_to => url_for(params))
# The error occurred while evaluating nil.size
# /home/conrad/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/cgi.rb:343:in `escape'
This is because $ variables are bound in the scope of the immediate caller to String#gsub not in the scope of the block you pass in.
Metadata
Metadata
Assignees
Labels
No labels