-
Notifications
You must be signed in to change notification settings - Fork 231
Fix Flash links #1549
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
Fix Flash links #1549
Conversation
Alternative approaches include
EDIT: On second thoughts, I have changed the code to option 3, as leaving the logic to the backend can be brittle (if we delete |
I think for now what you're doing in terms of using |
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.
- batch regrade link appears as expected and is pluralized, same with regrade all
- autograde submission appears as expected
- flashes still appear to function fine
- verified that escaping for new user with html in email works
LGTM!
Description
pluralize
flash[:html_safe] = true
whenever the flash should be displayed verbatim (if we know the whole string is safe and have a link that we want to display)html_safe
wheneverflash[:html_safe]
is set, hence not escapingmsg
Motivation and Context
Currently, there appears to be some attempts to mark flashes as
html_safe
in the controllers (from ~2015)html_safe
in the controller would ensure the flash message would not be escaped in the viewhtml_safe
(a terrible idea)Since #216,
sanitize(msg)
was used as an alternate way to mark messages ashtml_safe
. This prevents XSS attacks, but can lead to unexpected styling since tags are stripped but not escaped. This led to the removal ofsanitize
in #1532 altogether, to ensure that emails always appeared as expected.However, this meant that some legitimate uses of links in flashes would not show up properly. To counteract this, I am proposing the use of a "flag" via
flash[:html_safe]
that we can set totrue
should we need a string to display verbatim. Otherwise, by default, Rails will escape the flash message as usual.How Has This Been Tested?
Regrading x submissions
) -- note "submission" is conditionally pluralizedRegrading the most recent submissions from x students
) -- note "student" is conditionally pluralizedSubmitted file <user>_<ver>_<file>.c (Job ID = xx) for autograding. Refresh the page to see the results.
)type=email
from element)<strong>name</strong>@bademail.com
(bypassing validation by removing type from email field)Types of changes
Checklist:
overcommit --install && overcommit --sign
to use pre-commit hook for linting