Repository navigation
Escape page titles once when they are built - #3228
Draft
theseanything wants to merge 1 commit into
Draft
theseanything wants to merge 1 commit into
theseanything wants to merge 1 commit into
Conversation
set_page_title marked every title as html_safe, including form, group and user names that people type in. The rendered <title> only came out escaped because Array#join in page_title returns a plain String, which drops the html_safe flag before ERB outputs it. Anything reading content_for(:title) directly would get the raw markup. Let content_for escape the title when it is stored, and use safe_join in page_title so the result is not escaped a second time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-3228.admin.review.forms.service.gov.uk/ It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready For the sign in details and more information, see the review apps wiki page. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this pull request solve?
set_page_titlemarked every title ashtml_safe, including titles built from form, group, page and user names. The<title>only ended up escaped becauseArray#joininpage_titlereturns a plainString, so ERB escaped it on output. Anything readingcontent_for(:title)directly would get unescaped markup.This change lets
content_forescape the title when it's stored, and usessafe_joininpage_titleso the title is escaped exactly once. That keeps the fix from #125 for double-escaped characters such as apostrophes.