-
Notifications
You must be signed in to change notification settings - Fork 124
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
Don't blindly mark flash strings HTML safe #3229
Conversation
This is in partial fulfillment of #3228. Removing the `#html_safe` calls from this line avoids marking arbitrary strings as safe when they are very likely not. Providers of flash messages need to be refactored to manage the safety of the buffers they provide.
If I recall correctly, there is no way for flash messages, which get serialized into the session to be marked as HTML safe. I believe there are one or two places where we've inserted html link tags into the flash, so this change may break those links. |
How about calling |
@jcoyne I think I follow. Since the flash messages are serialized into the session using the JSON serializer, they come out as strings, even if there were originally safe buffers? Yeah, it seems like Do we have any example flash messages with HTML formatting? |
@no-reply that's what I'm thinking. Sorry, I don't know where we have html in the flash though. Maybe these?
|
Using `sanitize` cleans up flash messages with `Rails::Html::WhiteListSanitizer`. This view partial had originally marked all of the strings it received as `#html_safe`, effectively trusting all content. Using sanitize essentially does the opposite: distrusting all flash message content. Any tags or attributes not in the whitelist (https://github.com/flavorjones/loofah/blob/master/lib/loofah/html5/whitelist.rb) will be removed, regardless of the source. This seems like the best solution, since flash messages are serialized as strings, so the providers cannot give us carefully constructed `#html_safe` strings. In general, flash messages shouldn't require markup more complex than basic formatting and links. Fixes #3228 Connected to #3187
This view partial had originally marked all of the strings it received as
#html_safe
, effectively trusting all content. Using sanitize essentially does the opposite: distrusting all flash message content. Any tags or attributes not in the whitelist (https://github.com/flavorjones/loofah/blob/master/lib/loofah/html5/whitelist.rb) will be removed, regardless of the source.This seems like the best solution, since flash messages are serialized as strings, so the providers cannot give us carefully constructed
#html_safe
strings. In general, flash messages shouldn't require markup more complex than basic formatting and links.Fixes #3228
Connected to #3187
Changes proposed in this pull request:
map(&:html_safe)
!!!sanitize
on flash messagesGuidance for testing, such as acceptance criteria or new user interface behaviors:
@samvera/hyrax-code-reviewers