-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Handle more unsafe String methods #33990
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
Handle more unsafe String methods #33990
Conversation
|
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sgrif (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
|
|
||
| UNSAFE_STRING_METHODS.each do |unsafe_method| | ||
| if unsafe_method.respond_to?(unsafe_method) | ||
| if String.method_defined?(unsafe_method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speed is not a problem here. This loop only run once, UNSAFE_STRING_METHODS times, so I prefer to keep the respond_to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafaelfranca OK, changed back.
|
Thanks! |
ActiveSupport SafeBuffer now html escapes on insert in Rails 6. This will work around the issue by marking our injected script as safe. See also: rails/rails#33990
In Rails 6, the spec of `ActiveSupport::SafeBuffer#insert` has been changed. Previously, it behaves like just String, but now `ActiveSupport::SafeBuffer` exactlly. See for details: rails/rails#33990
In Rails 6, the spec of `ActiveSupport::SafeBuffer#insert` has been changed. Previously, it behaves like just String, but now `ActiveSupport::SafeBuffer` exactly. See for details: rails/rails#33990
ActiveSupport SafeBuffer now html escapes on insert in Rails 6. This will work around the issue by marking our injected script as safe. See also: rails/rails#33990
Summary
#delete_prefix(!),#delete_suffix(!), and#unicode_normalize(!)toUNSAFE_STRING_METHODS:#[]=,#insertand#replacethe same way#prependand#concatare already treated:greatly improves test coverage of unsafe String methods
replaces the obscure.unsafe_method.respond_to?(unsafe_method)with the fasterString.method_defined?(unsafe_method)