angular/packages
crisbeto 7f689a291a fix(compiler): incorrectly encapsulating @import containing colons and semicolons (#38716)
At a high level, the current shadow DOM shim logic works by escaping the content of a CSS rule
(e.g. `div {color: red;}` becomes `div {%BLOCK%}`), using a regex to parse out things like the
selector and the rule body, and then re-adding the content after the selector has been modified.
The problem is that the regex has to be very broad in order capture all of the different use cases,
which can cause it to match strings suffixed with a semi-colon in some places where it shouldn't,
like this URL from Google Fonts `https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap`.
Most of the time this is fine, because the logic that escapes the rule content to `%BLOCK%` will
have converted it to something that won't be matched by the regex. However, it breaks down for rules
like `@import` which don't have a body, but can still have quoted content with characters that can
match the regex.

These changes resolve the issue by making a second pass over the escaped string and replacing all
of the remaining quoted content with `%QUOTED%` before parsing it with the regex. Once everything
has been processed, we make a final pass where we restore the quoted content.

In a previous iteration of this PR, I went with a shorter approach which narrowed down the
regex so that it doesn't capture rules without a body. It fixed the issue, but it also ended
up breaking some of the more contrived unit test cases. I decided not to pursue it further, because
we would've ended up with a very long and brittle regex that likely would've broken in even weirder
ways.

Fixes #38587.

PR Close #38716
2020-10-09 08:33:04 -07:00
..
animations Revert "build: remove wombot proxy registry from package.jsons for release (#37378)" (#37495) 2020-06-10 08:21:45 -07:00
bazel feat(core): remove ViewEncapsulation.Native (#38882) 2020-10-08 11:56:03 -07:00
benchpress build: add wombot proxy for publish config for @angular/benchpress (#37752) 2020-06-25 17:08:18 -07:00
common refactor(common): remove i (ignore case) regex flag where it is not needed (#39077) 2020-10-07 13:31:59 -07:00
compiler fix(compiler): incorrectly encapsulating @import containing colons and semicolons (#38716) 2020-10-09 08:33:04 -07:00
compiler-cli feat(core): remove ViewEncapsulation.Native (#38882) 2020-10-08 11:56:03 -07:00
core feat(core): remove ViewEncapsulation.Native (#38882) 2020-10-08 11:56:03 -07:00
docs docs(di): fix typo in advanced di doc (#36634) 2020-05-01 09:50:28 -07:00
elements feat(compiler-cli): add support for TypeScript 4.0 (#38076) 2020-08-24 13:06:59 -07:00
examples docs: remove explicit boolean type in examples as TS infers it automatically (#39081) 2020-10-06 08:39:01 -07:00
forms fix(forms): improve types of directive constructor arguments (#38944) 2020-10-06 10:14:21 -07:00
language-service test(language-service): test ICU expressions in hybrid visitor (#39072) 2020-10-08 11:55:27 -07:00
localize build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#39182) 2020-10-08 11:54:59 -07:00
misc/angular-in-memory-web-api feat(core): update reference and doc to change async to waitAsync. (#37583) 2020-08-03 12:54:13 -07:00
platform-browser feat(core): remove ViewEncapsulation.Native (#38882) 2020-10-08 11:56:03 -07:00
platform-browser-dynamic feat(core): update reference and doc to change async to waitAsync. (#37583) 2020-08-03 12:54:13 -07:00
platform-server feat(core): remove ViewEncapsulation.Native (#38882) 2020-10-08 11:56:03 -07:00
private/testing build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
router fix(router): properly assign ExtraOptions to Router in RouterTestingModule (#39096) 2020-10-05 16:35:14 -07:00
service-worker feat(service-worker): add the option to prefer network for navigation requests (#38565) 2020-09-22 09:29:20 -07:00
upgrade fix(upgrade): add try/catch when downgrading injectables (#38671) 2020-09-10 08:50:15 -07:00
zone.js build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#39182) 2020-10-08 11:54:59 -07:00
BUILD.bazel build: upgrade angular build, integration/bazel and @angular/bazel package to rule_nodejs 2.2.0 (#39182) 2020-10-08 11:54:59 -07:00
circular-deps-test.conf.js fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846) 2020-09-30 09:13:59 -04:00
empty.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
goog.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
license-banner.txt build: bump year (#34651) 2020-01-13 07:21:43 -08:00
README.md docs: add doc reference to npm package readme (#33911) 2019-11-20 14:46:23 -08:00
system.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
tsconfig-build-no-strict.json refactor(core): ensure compatibility with typescript strict flag (#30993) 2019-07-18 14:21:25 -07:00
tsconfig-build.json refactor(core): ensure compatibility with typescript strict flag (#30993) 2019-07-18 14:21:25 -07:00
tsconfig-test.json refactor: fix typescript strict flag failures in all tests (#30993) 2019-07-18 14:21:26 -07:00
tsconfig.json fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846) 2020-09-30 09:13:59 -04:00
types.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT