14102 Commits

Author SHA1 Message Date
Alan Agius d1ca8ae043 fix(compiler): prevent XSS via SVG animation attributeName and MathML/SVG URLs
This commit implements a security fix to prevent XSS vulnerabilities where SVG animation elements (`<animate>`, `<set>`, etc.) could be used to modify the `href` or `xlink:href` attributes of other elements to `javascript:` URLs.

The fix introduces a runtime validation step:
- A new [ɵɵValidateAttribute](cci:1://file:///usr/local/google/home/alanagius/git/angular/packages/core/src/sanitization/sanitization.ts:276:0-288:1) instruction is used when `attributeName` is bound on SVG animation elements.
- If executed, a `RuntimeError` is thrown, preventing the binding.
- The compiler now identifies `attributeName` on SVG animation elements as security-sensitive and injects this validation.

Additionally, the DOM security schema has been updated to include a comprehensive list of MathML and SVG elements that accept `href` or `xlink:href` attributes, ensuring they are correctly treated as `SecurityContext.URL` and sanitized. This prevents malicious URLs from being bound to these attributes.

http://b/463880509
2025-12-01 10:29:30 +01:00
Alan Agius 0276479e7d fix(http): prevent XSRF token leakage to protocol-relative URLs
The XSRF interceptor previously failed to detect protocol-relative URLs (starting with `//`) as absolute URLs. This allowed requests to such URLs to include the XSRF token, potentially leaking it to external domains.

This change updates the interceptor to correctly identify protocol-relative URLs as absolute and exclude them from receiving the XSRF token.
2025-11-25 13:54:57 -05:00
Jessica Janiuk 820bb3991c Revert "refactor(core): let the profiler handle asymmetric events leniently"
This reverts commit da9911f2b4.

(cherry picked from commit 88dfd96ec9)
2025-11-17 18:10:40 +00:00
Jessica Janiuk 2dccdcd6bc Revert "fix(core): notify profiler events in case of errors"
This reverts commit af1ba52587.

(cherry picked from commit adc2a57be0)
2025-11-17 18:10:40 +00:00
JoostK a966ff18d4 refactor(core): let the profiler handle asymmetric events leniently
Although the prior commit has made more profiler events guaranteed symmetric
through the use of finally-blocks, there continue to be some situations
that could potentially result in asymmetric events, e.g. application
bootstrap doesn't guarantee symmetric events. This commit makes the profiler
lenient to these situations by unrolling the stack past the asymmetric event
data, eventually reaching the expected start event.

(cherry picked from commit da9911f2b4)
2025-11-17 17:40:09 +00:00
JoostK 52cf65892a fix(core): notify profiler events in case of errors
Profiler events are expected to be symmetric, yet in the case of errors this symmetry may break
if events aren't always kept in sync with their corresponding start event. This commit moves
various end events to be run from a finally-block, allowing them to notify the profiler even
when an error has occurred.

Fixes #62947

(cherry picked from commit af1ba52587)
2025-11-17 17:40:09 +00:00
SkyZeroZx daae2636d5 docs: Adds links to relevant guides for APIs in core package
(cherry picked from commit 0432e76171)
2025-11-17 16:47:38 +00:00
SkyZeroZx d10f1107a8 docs: add documentation for HostAttributeToken
(cherry picked from commit d70310896c)
2025-11-17 16:47:02 +00:00
SkyZeroZx 2c3691dc1a docs: add documentation for DOCUMENT injection token usage in SSR
(cherry picked from commit 846d50ab23)
2025-11-17 16:28:04 +00:00
Matthew Beck f689269eca Revert "fix(compiler): support one additional level of nesting in :host()"
This reverts commit 036c5d2a07.
2025-11-13 15:44:25 -08:00
Matthew Beck 7b2e6caaf8 Revert "fix(compiler): support arbitrary nesting in :host-context()"
This reverts commit f9d0818087.
2025-11-13 15:44:25 -08:00
Matthew Beck 6036eef73c Revert "fix(compiler): support commas in :host() argument"
This reverts commit 106b9040df.
2025-11-13 15:44:25 -08:00
Matthew Beck a44658ba3e Revert "fix(compiler): support complex selectors in :nth-child()"
This reverts commit 9419ea348a.
2025-11-13 15:44:25 -08:00
SkyZeroZx 06bc1467b1 docs: adds guide references to router APIs
Adds `@see` tags with links to relevant guides in the router documentation.

(cherry picked from commit 718eb7bb3a)
2025-11-13 18:00:23 +00:00
Matthieu Riegler a02b957b60 refactor(core): remove resource flag.
This was used to migrate G3 and is no longer necessary.

(cherry picked from commit d1ab73dd87)
2025-11-13 17:12:21 +00:00
Matthew Beck 9419ea348a fix(compiler): support complex selectors in :nth-child()
:nth-child() (and its siblings) support complex expressions, e.g.
`:nth-child(2n of :is(.foo, .bar))`. Previously we'd choke because of
the `:is()`. Now, we reuse the `_parenSuffix` subexpression to match
nested parentheses the same way we do for :host() and :host-context().
Note that we only support 3 levels of nesting, so a selector like
`:nth-child(n of :is(:has(:not(.foo))))` will still break.

I'll say yet again that we really should add a proper parser so we stop
getting bug reports like this :)

Fixes #64913

(cherry picked from commit 24cfd5a0ed)
2025-11-11 14:03:36 -08:00
Andrew Scott f00fb46347 Revert "feat(service-worker): notify clients about version failures (#62718)"
This reverts commit 6d011687ec.

issue #63500 reproduces at head on the main branch in the dev app.
Reverting this change along resolves it.

fixes https://github.com/angular/angular/issues/63500

(cherry picked from commit 4af408afcb)
2025-11-11 12:48:48 -08:00
SkyZeroZx a8c577d3af docs: add reference to Built-in Pipes in multiple pipe files
(cherry picked from commit d999667b57)
2025-11-11 08:47:11 -08:00
SkyZeroZx c59fa8b85a docs: improve discoverability in service worker documentation
(cherry picked from commit dde18c2303)
2025-11-11 08:32:18 -08:00
Andrew Kushnir 8922cae0f9 Revert "refactor(http): migrate XSRF classes to use inject() function"
This reverts commit 2ad6b729a1.

Revert reason: the change relies on the code that is not available in the `20.3.x` branch (the `HttpXsrfCookieExtractor` class is not marked as `providedIn: "root"`).
2025-11-10 13:56:23 -08:00
arturovt 5047849a4a fix(common): remove placeholder image listeners once view is removed
Prior to this commit, attempting to resolve a `ChangeDetectorRef` after views or app have been destroyed would result in an error. In this commit, we clean up listeners once the view is destroyed, before the placeholder loads or fails to load.

(cherry picked from commit feb86e3fde)
2025-11-10 12:05:23 -08:00
arturovt 4c66fe4796 refactor(core): mark VERSION as @__PURE__ for better tree-shaking
Annotate the `new Version(...)` call with `/* @__PURE__ */` to signal to optimizers that the constructor is side-effect free.

Without this hint, bundlers such as Terser or ESBuild may conservatively retain the `VERSION` instantiation even when unused. With the annotation, the constant can be tree-shaken away in production builds if not referenced, reducing bundle size.

(cherry picked from commit d3f67f6ca8)
2025-11-10 12:04:08 -08:00
SkyZeroZx 2ad6b729a1 refactor(http): migrate XSRF classes to use inject() function
Remove constructor injection in favor of inject() calls

(cherry picked from commit 55be477979)
2025-11-10 09:49:13 -08:00
SkyZeroZx 7b1a47866a docs: improve discoverability of forms
(cherry picked from commit e3fc57e8fc)
2025-11-10 07:57:47 -08:00
Matthew Beck 2531863909 test(compiler): add test for :host:has(> .foo)
I took a quick look at my recent changes to see if I had inadvertently
fixed this bug, but I couldn't seem to reproduce it even before my
changes. Seems like it's working, though.

Closes #58436

(cherry picked from commit 4b871b139b)
2025-11-10 07:51:20 -08:00
Matthew Beck 106b9040df fix(compiler): support commas in :host() argument
This change adds support for commas in :host() arguments (e.g.
`:host(:not(.foo, .bar))` as well as in nested parens when the argument
is applied without parens (e.g. `:host:not(:has(.foo, .bar))`).
Previously these selectors would receive an extra `[nghost]` attr, e.g.
`[nghost]:not(.foo, [nghost].bar)`.

I didn't file a bug for this one, but it's also blocking on an internal
LSC. Like the other CSS changes, I'll run a TGP to confirm this isn't
breaking.
2025-11-10 07:49:19 -08:00
Matthew Beck f9d0818087 fix(compiler): support arbitrary nesting in :host-context()
Previously we supported one level of nested pseudo-element selectors
inside :host-context(), e.g. :host-context(:is(.foo, .bar)). This was
based on a regex-based approach. We could support deeper levels of
nesting by updating the regex, but using a regex approach prohibits us
from supporting arbitrary nesting.

Rather than just adding one more level to the existing expression, I've
added a new generator function which splits selectors on commas in a
parenthesis-aware way. This allows us to support arbitrary nesting.

It's likely we'll want to reuse this in other places where we're not as
careful today. We'll probably do this on a request-based basis, though.

Fixes #59176
2025-11-10 07:49:19 -08:00
Andrew Kushnir b47054c52e Revert "fix(compiler): support commas in :host() argument"
This reverts commit 1e09bdc114.

Revert reason: the change relies on helper functions that do not exist in `20.3.x` branch (only exist in `main`).
2025-11-07 16:03:07 -08:00
Matthew Beck 1e09bdc114 fix(compiler): support commas in :host() argument
This change adds support for commas in :host() arguments (e.g.
`:host(:not(.foo, .bar))` as well as in nested parens when the argument
is applied without parens (e.g. `:host:not(:has(.foo, .bar))`).
Previously these selectors would receive an extra `[nghost]` attr, e.g.
`[nghost]:not(.foo, [nghost].bar)`.

I didn't file a bug for this one, but it's also blocking on an internal
LSC. Like the other CSS changes, I'll run a TGP to confirm this isn't
breaking.

(cherry picked from commit 680c3c7bff)
2025-11-07 10:43:36 -08:00
tsc036 41466a7bbf refactor(core): move profile_types.ts to primtives
move profile_types.ts so the types can be used in Wiz code

(cherry picked from commit cf47ce2db9)
2025-11-06 22:22:37 +00:00
SkyZeroZx 1dcecdf823 refactor(platform-browser): remove unused Platform ID dependency from DomRendererFactory2
Eliminates the unnecessary injection and usage of Platform ID in the renderer factory logic, along with related test scaffolding cleanup

(cherry picked from commit 5343001835)
2025-11-06 20:00:49 +00:00
Matthew Berry 036c5d2a07 fix(compiler): support one additional level of nesting in :host()
Previously we supported one level of nested parentheses inside of a
`:host()` selector, e.g. `:host(:not(p))`. This caused a breakage in g3
when I migrated a selector from `:host:not(:has(p))` to
`:host(:not(:has(p)))`. This change adds support for just one more level
of nesting.

It'd be nice to move everything to a real CSS parser (or even update it
to count parentheses like I did with :host-context()), but I wasn't able
to get that to work in ~20 minutes and I'm focusing on other things at
the moment.

This change punts the problem until somebody tries to use just one more
level of nesting in a selector.

Fixes #64830

(cherry picked from commit 444143758e)
2025-11-06 18:53:46 +00:00
Alan Agius ee578d3e86 build: format md files
Format all md files
2025-11-06 10:10:22 -08:00
Jessica Janiuk dcdd1bcdbb fix(core): skip leave animations on view swaps
We accounted for skipping leave animations during moves, but not swaps.
This accounts for the swap cases and updates how we deal with swaps and
moves. Now we always queue animations and then essentially dequeue them
if we attach them back in the same render pass.

fixes: #64818
fixes: #64730
2025-11-06 09:46:52 -08:00
tsc036 d6ef181f6c refactor(core): export types from primitives
export Version type and a type for linkedSignal previous value so they can be used for the Wiz implementations

(cherry picked from commit 104f7d57c1)
2025-11-06 16:34:57 +00:00
SkyZeroZx 744cd5c51c refactor(http): simplifies destruction tracking using destroyed property
Replaces the manual destroyed state with destroyed property

(cherry picked from commit 44435ea97b)
2025-11-05 09:05:32 -08:00
Lukas Matta a45e6b2b66 fix(migrations): Prevent removal of templates referenced with preceding whitespace characters
In https://github.com/angular/angular/pull/64745, a fix was introduced for templates referenced with a trailing semicolon. However, templates are still incorrectly removed when there are whitespace characters before the template name.

This commit updates the control flow migration logic to ensure templates referenced with preceding whitespace are not removed.

Fixes #64854

(cherry picked from commit 5b210e97af)
2025-11-04 15:26:06 -08:00
SkyZeroZx 7438b9cc26 refactor(core): Removes unused flag for onDestroy
Eliminates an unnecessary configuration flag

(cherry picked from commit 2ad1b5979f)
2025-11-03 20:21:04 -08:00
Kristiyan Kostadinov 840db59dc1 fix(compiler-cli): make required inputs diagnostic less noisy
Currently when a required input is missing, we produce a diagnostic on the entire start tag. This can be really noisy if there are already some attributes on the element.

This change switch to only highlighting the tag name instead.

(cherry picked from commit f233f7420a)
2025-11-03 13:27:51 -08:00
Matthieu Riegler 1572bafa45 refactor(core): Replace usages of the Function type for animations
`Function` is usually not recommended as its not specific enough.

(cherry picked from commit 79b7ac722a)
2025-11-03 12:05:06 -08:00
Lukas Matta 2edc82abe0 fix(migrations): Do not remove a template if it is referenced even with a trailing semilocon
This commit fixes a behavior where under certain conditions, the migration script ignored
a template reference with a trailing semicolon and incorrectly removed the definition
of a referenced template.

Fixes #64741

(cherry picked from commit 64cb08529d)
2025-10-29 10:51:00 +01:00
Shuaib Hasan Akib 385bcbc2c0 refactor(router): remove redundant default value from routerOutletData input
Since `input()` defaults to `undefined`, the explicit initializer was unnecessary.
This improves clarity and reduces boilerplate.

(cherry picked from commit 8291760f9b)
2025-10-28 10:24:26 +01:00
Matt Lewis ca3fd7847f fix(core): Clear lView from IcuIteratorState when stack is empty to prevent memory leak
If a component template contains an icu expression it is being retained until the next change detection cycle for that template. This results in a net retention of only ever a single copy of the given lView but that creates an opportunity for compounding leaks.

Change the icu i18n_icu_container_visitor to free the IcuIteratorState retained lView when the stack is empty so that garbage collection can occur when the view is discarded.

(cherry picked from commit 59e648913c)
2025-10-27 19:42:21 +01:00
SkyZeroZx 5ce9d881e3 docs: Adds guide links to HTTP API docs for better discoverability
(cherry picked from commit c5e6b8bdc8)
2025-10-27 09:25:59 +01:00
Alan Agius 6daabb08e6 Revert "build: refactor location of best-practices.md"
This reverts commit 07a51872d5.

(cherry picked from commit 620e2c4926)
2025-10-24 19:02:41 +02:00
SkyZeroZx 020f17694b feat(common): Blocks IPv6 localhost from preconnect checks
Prevents unnecessary preconnect warnings by adding IPv6 loopback ('[::1]') to the blocklist.

(cherry picked from commit a3639e2258)
2025-10-24 18:46:47 +02:00
SkyZeroZx 752986bfc2 refactor(common): Add missing OnDestroy interface in PreconnectLinkChecker
The OnDestroy interface was implemented but not declared; this adds the missing interface declaration

(cherry picked from commit 207baad322)
2025-10-24 18:46:47 +02:00
Andrew Scott 4b318d0cc0 fix(zone.js): Support jasmine v6
This fixes the jasmine patch to ensure we are patching the private APIs
off of the right location, which changed in v6.

see https://github.com/jasmine/jasmine/commit/168ff0a751b6280b170ce097410d77a4c7c1f449

(cherry picked from commit 48abe007d9)
2025-10-24 18:46:08 +02:00
Alan Agius 18c70315d7 build: refactor location of best-practices.md
This commit moves the best-practices.md file from adev/src/context to packages/core/resources. The BUILD.bazel files and other configuration files have been updated to reflect this change.

(cherry picked from commit 07a51872d5)
2025-10-24 18:45:35 +02:00
SkyZeroZx 50d2670495 docs: Add router config options (#64529)
PR Close #64529
2025-10-23 12:34:57 +02:00