Skip to content

fix(material/icon): escape the path prefixed to FuncIRI references - #34160

Open
moamenmahmod wants to merge 1 commit into
angular:mainfrom
moamenmahmod:fix/material-icon-funciri-escaping
Open

moamenmahmod wants to merge 1 commit into
angular:mainfrom
moamenmahmod:fix/material-icon-funciri-escaping

Conversation

@moamenmahmod

Copy link
Copy Markdown
Contributor

Escapes backslashes and single quotes in the path (and in the id) before they are interpolated into the url('…') value in _prependPathToReferences, so a path containing a literal quote cannot terminate the string and add further URL tokens to the attribute. The leading-slash normalization added in #33812 is unchanged, and a path with no ' or \ produces exactly the same value as before.

Verified against Chrome's CSS parser: today's value parses as two url() tokens when the path contains a quote (the second one resolving to another origin); with this change it parses as a single token on the current origin.

Adds two regression tests next to the existing FuncIRI tests, covering a quote breakout and a backslash + quote path. Both assert that stripping the escape sequences leaves a single quoted URL, which fails on the current code and passes with this change.

Fixes #34159

`_prependPathToReferences` interpolates the current path into a quoted
CSS `url('...')` string. Since a literal single quote is preserved in
`location.pathname`, such a path could close that string and append
further URL tokens to the attribute, which `mask` and `filter` accept
as a list. Escape backslashes and single quotes before interpolating,
so the value always resolves to exactly one reference on the current
origin. The id is escaped the same way.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(material/icon): FuncIRI references can be broken out of the quoted url() string

1 participant