Skip to content

[Backport 21.2.X] fix(@angular/build): escape prerender redirect URLs - #34508

Merged
alan-agius4 merged 2 commits into
angular:21.2.xfrom
SkyZeroZx:fix/escape-prerender-redirect-urls-21.2.x
Oct 26, 2026
Merged

alan-agius4 merged 2 commits into
angular:21.2.xfrom
SkyZeroZx:fix/escape-prerender-redirect-urls-21.2.x

Conversation

@SkyZeroZx

Copy link
Copy Markdown
Contributor

Backport of #33248

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces HTML escaping for URLs interpolated into static redirect pages to prevent potential injection vulnerabilities. It adds an escapeHtml utility and updates generateRedirectStaticPage to escape characters like ampersands, angle brackets, and quotes. Unit and end-to-end tests are also added to verify the escaping behavior. Feedback suggests adding a nullish coalescing fallback in escapeHtml to prevent returning undefined if the regex is modified in the future without updating the character map.

Comment thread packages/angular/build/src/utils/server-rendering/utils.ts
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: lts This PR is targeting a version currently in long-term support labels Oct 26, 2026
Escape redirect targets before embedding them in the meta refresh tag and the fallback link of
generated static redirect pages.
@alan-agius4
alan-agius4 force-pushed the fix/escape-prerender-redirect-urls-21.2.x branch from 448de28 to 647a33a Compare October 26, 2026 10:29
@alan-agius4 alan-agius4 added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Oct 26, 2026
@alan-agius4
alan-agius4 merged commit 1816466 into angular:21.2.x Oct 26, 2026
32 of 34 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: lts This PR is targeting a version currently in long-term support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants