Skip to content

fix(core): use the custom Sanitizer for URLs in i18n attributes - #72035

Merged
amishne merged 1 commit into
angular:mainfrom
phr4nky:fix-i18n-custom-url-sanitizer
Nov 17, 2026
Merged

amishne merged 1 commit into
angular:mainfrom
phr4nky:fix-i18n-custom-url-sanitizer

Conversation

@phr4nky

@phr4nky phr4nky commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

Translated attributes with interpolations in a URL context, e.g.

<a i18n-href href="{{url}}"></a>
<div i18n>{count, plural, other {<a href="{{url}}">link</a>}}</div>

are sanitized at runtime by i18nResolveSanitizer with the raw _sanitizeUrl function. Unlike the ɵɵsanitize* instructions, it does not consult a Sanitizer provided by the application ({provide: Sanitizer, useValue: ...}). All other security contexts (HTML, style, script, resource URL) in the same function already use the ɵɵsanitize* instructions, and the compile-time path for static i18n attributes emits ɵɵsanitizeUrl as well, so URLs were the only inconsistent case.

Issue Number: N/A

What is the new behavior?

i18nResolveSanitizer returns ɵɵsanitizeUrl for the URL context, so a custom Sanitizer is used for translated URL attributes just like for regular bindings. Without a custom Sanitizer the behavior is unchanged (ɵɵsanitizeUrl falls back to _sanitizeUrl).

The new tests in i18n_spec.ts fail without the change (Expected 'unsafe:javascript:…' to be 'custom:javascript:…') and pass with it.

Does this PR introduce a breaking change?

  • No

@pullapprove
pullapprove Bot requested a review from atscott November 13, 2026 16:42
@google-cla

google-cla Bot commented Nov 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Nov 13, 2026
@ngbot ngbot Bot added this to the Backlog milestone Nov 13, 2026
@phr4nky
phr4nky force-pushed the fix-i18n-custom-url-sanitizer branch from 57f5a11 to 98ebad6 Compare November 13, 2026 16:46
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Nov 16, 2026
@JeanMeche
JeanMeche removed the request for review from atscott November 16, 2026 15:34
@phr4nky
phr4nky force-pushed the fix-i18n-custom-url-sanitizer branch from 98ebad6 to 4cdd48b Compare November 16, 2026 15:47
Translated attributes with interpolations in a URL context (e.g.
`<a i18n-href href="{{url}}">` or an `href` inside an ICU case) were
sanitized with the raw `_sanitizeUrl` function, which ignores a
`Sanitizer` provided by the application. All other security contexts
already go through the `ɵɵsanitize*` instructions, as does the
compile-time path for static i18n attributes.

Use `ɵɵsanitizeUrl` for the URL context as well, so a custom
`Sanitizer` is consulted consistently.
@phr4nky
phr4nky force-pushed the fix-i18n-custom-url-sanitizer branch from 4cdd48b to b912325 Compare November 16, 2026 19:46
@angular-robot
angular-robot Bot requested a review from JeanMeche November 16, 2026 19:46
@thePunderWoman thePunderWoman added target: rc This PR is targeted for the next release-candidate and removed target: patch This PR is targeted for the next patch release labels Nov 16, 2026
@thePunderWoman
thePunderWoman removed the request for review from JeanMeche November 16, 2026 23:24
@amishne
amishne merged commit ca92b96 into angular:main Nov 17, 2026
25 checks passed
@amishne

amishne commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

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: core Issues related to the framework runtime target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants