[Backport 20.3.X] fix(http): enable XSRF protection for same-origin absolute URLs by SkyZeroZx · Pull Request #71295 · angular/angular · GitHub
Skip to content

[Backport 20.3.X] fix(http): enable XSRF protection for same-origin absolute URLs - #71295

Merged
amishne merged 4 commits into
angular:20.3.xfrom
SkyZeroZx:backport-65683-to-20.3.x
Oct 14, 2026
Merged

amishne merged 4 commits into
angular:20.3.xfrom
SkyZeroZx:backport-65683-to-20.3.x

Conversation

@SkyZeroZx

@SkyZeroZx SkyZeroZx commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Backport of #65683

Also gives the XSRF provider specs a page URL, because TestBed on 20.3.x provides MockPlatformLocation without a start URL, and adds specs for backslash and whitespace URLs.

Fixes #71294

TestBed on this branch provides MockPlatformLocation without a start
URL, so its href is "//" and an origin check cannot parse it.
@angular-robot angular-robot Bot added the area: common/http Issues related to HTTP and HTTP Client label Oct 11, 2026
@ngbot ngbot Bot added this to the Backlog milestone Oct 11, 2026
alan-agius4 and others added 2 commits October 11, 2026 00:25
Previously, the XSRF interceptor only added the XSRF token to requests with relative URLs.
This commit updates the interceptor to also add the token to requests with absolute URLs, provided they match the current origin.

Fixes angular#71294

(cherry picked from commit 0659d11)
Browsers resolve these URLs to another origin, so the interceptor must
not attach the XSRF token to them.
@SkyZeroZx
SkyZeroZx force-pushed the backport-65683-to-20.3.x branch from 21df429 to 9b278c0 Compare October 11, 2026 05:25
@SkyZeroZx
SkyZeroZx marked this pull request as ready for review October 11, 2026 05:25
Comment thread packages/common/http/test/xsrf_spec.ts
@JeanMeche JeanMeche added PullApprove: disable target: lts This PR is targeting a version currently in long-term support labels Oct 12, 2026
@SkyZeroZx
SkyZeroZx requested a review from JeanMeche October 12, 2026 17:08
@JeanMeche

Copy link
Copy Markdown
Member

The i18n sub-system has the `changeMask` and `changeMaskCounter` flags which are set by i18n-related instructions and reset once the state is applied. The problem is that if something throws within the application logic, the flags would never be reset. This is currently causing flakes in our CI runs.

These changes resolve the issue by adding a try/finally around the flags.

(cherry picked from commit 6339d26)
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Oct 13, 2026
@JeanMeche JeanMeche added the action: merge The PR is ready for merge by the caretaker label Oct 13, 2026
@amishne
amishne merged commit fc0e50a into angular:20.3.x Oct 14, 2026
21 checks passed
@amishne

amishne commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

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: common/http Issues related to HTTP and HTTP Client area: core Issues related to the framework runtime PullApprove: disable 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.

5 participants