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

Don't blindly mark flash strings HTML safe #3229

Merged
merged 2 commits into from
Aug 31, 2018
Merged

Don't blindly mark flash strings HTML safe #3229

merged 2 commits into from
Aug 31, 2018

Commits on Aug 30, 2018

  1. Don't blindly mark flash strings HTML safe

    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.
    Tom Johnson committed Aug 30, 2018
    Configuration menu
    Copy the full SHA
    9d4d7f1 View commit details
    Browse the repository at this point in the history

Commits on Aug 31, 2018

  1. Scrub flash messages with SanitizeHelper#sanitize before display

    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
    Tom Johnson committed Aug 31, 2018
    Configuration menu
    Copy the full SHA
    47e996e View commit details
    Browse the repository at this point in the history