From 63d1dd70cda03ffd9591bed15ff796194a375865 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Tue, 21 May 2024 00:27:26 +0100 Subject: [PATCH 1/7] Fix and test for bug #1457 (Uncaught SyntaxError: Regular expression too large) - see test case which is extracted from a real world css file; the selector regex was able to traverse the curly brace as when looking for quotes, it wasn't taking into account that the start quote could be escaped --- packages/rrweb-snapshot/src/css.ts | 2 +- packages/rrweb-snapshot/test/rebuild.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/rrweb-snapshot/src/css.ts b/packages/rrweb-snapshot/src/css.ts index 82b4c41f96..b795e21223 100644 --- a/packages/rrweb-snapshot/src/css.ts +++ b/packages/rrweb-snapshot/src/css.ts @@ -439,7 +439,7 @@ export function parse(css: string, options: ParserOptions = {}) { } // Use match logic from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1 - const m = match(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/); + const m = match(/^(((? { + // the ':hover' in the below is a decoy which is not part of the selector, + // previously that part was being incorrectly consumed by the selector regex + const should_not_modify = + ".tailwind :is(.before\\:content-\\[\\'\\'\\])::before { --tw-content: \":hover\"; content: var(--tw-content); }.tailwind :is(.\\[\\&\\>li\\]\\:before\\:content-\\[\\'-\\'\\] > li)::before { color: pink; }"; + expect(adaptCssForReplay(should_not_modify, cache)).toEqual( + should_not_modify, + ); + }); }); From d45c841eab3faabf24a94d745b2bbdb382e0f761 Mon Sep 17 00:00:00 2001 From: eoghanmurray Date: Mon, 20 May 2024 23:37:21 +0000 Subject: [PATCH 2/7] Apply formatting changes --- .changeset/eleven-bobcats-peel.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/eleven-bobcats-peel.md diff --git a/.changeset/eleven-bobcats-peel.md b/.changeset/eleven-bobcats-peel.md new file mode 100644 index 0000000000..e3dbcf911e --- /dev/null +++ b/.changeset/eleven-bobcats-peel.md @@ -0,0 +1,6 @@ +--- +"rrweb-snapshot": patch +"rrweb": patch +--- + +better support for coexistence with older libraries (e.g. MooTools & Prototype.js) which modify the in-built `Array.from` function From dc7b28335e2df9471a7a994887421f879e56c476 Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Tue, 21 May 2024 00:37:44 +0100 Subject: [PATCH 3/7] Create fair-ducks-clean.md --- .changeset/fair-ducks-clean.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/fair-ducks-clean.md diff --git a/.changeset/fair-ducks-clean.md b/.changeset/fair-ducks-clean.md new file mode 100644 index 0000000000..19269db760 --- /dev/null +++ b/.changeset/fair-ducks-clean.md @@ -0,0 +1,6 @@ +--- +"rrweb-snapshot": patch +"rrweb": patch +--- + +Fix and test for bug #1457 which was affecting replay of complex tailwind css From ecd7f3de735012832a0d7ee7df3f74b9c725564f Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Wed, 22 May 2024 11:01:46 +0100 Subject: [PATCH 4/7] Fix @import regex bit which was stopping consumption in the middle of a url - need to consume quotes. Thanks dave.kindel@pendo.io for reporting and isolating this case --- packages/rrweb-snapshot/src/css.ts | 12 +++++++++++- packages/rrweb-snapshot/test/rebuild.test.ts | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/rrweb-snapshot/src/css.ts b/packages/rrweb-snapshot/src/css.ts index b795e21223..7d8ca68056 100644 --- a/packages/rrweb-snapshot/src/css.ts +++ b/packages/rrweb-snapshot/src/css.ts @@ -860,7 +860,17 @@ export function parse(css: string, options: ParserOptions = {}) { */ function _compileAtrule(name: string) { - const re = new RegExp('^@' + name + '\\s*([^;]+);'); + const re = new RegExp( + '^@' + + name + + '\\s*((?:' + + [ + '(? { const pos = position(); const m = match(re); diff --git a/packages/rrweb-snapshot/test/rebuild.test.ts b/packages/rrweb-snapshot/test/rebuild.test.ts index bf57a21ec4..2f5a307df7 100644 --- a/packages/rrweb-snapshot/test/rebuild.test.ts +++ b/packages/rrweb-snapshot/test/rebuild.test.ts @@ -166,4 +166,13 @@ describe('rebuild', function () { should_not_modify, ); }); + + it('should not incorrectly interpret at rules', () => { + // the ':hover' in the below is a decoy which is not part of the selector, + const should_not_modify = + '@import url("https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,400;0,500;0,700;1,400&display=:hover");'; + expect(adaptCssForReplay(should_not_modify, cache)).toEqual( + should_not_modify, + ); + }); }); From 25deb6d1459998015b5a7c06b20a667ad9461846 Mon Sep 17 00:00:00 2001 From: Jesse Wang Date: Fri, 21 Jun 2024 10:02:32 -0700 Subject: [PATCH 5/7] AMP-99342: Changeset clean-up --- .changeset/eleven-bobcats-peel.md | 6 ------ .changeset/fair-ducks-clean.md | 6 ------ 2 files changed, 12 deletions(-) delete mode 100644 .changeset/eleven-bobcats-peel.md delete mode 100644 .changeset/fair-ducks-clean.md diff --git a/.changeset/eleven-bobcats-peel.md b/.changeset/eleven-bobcats-peel.md deleted file mode 100644 index e3dbcf911e..0000000000 --- a/.changeset/eleven-bobcats-peel.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"rrweb-snapshot": patch -"rrweb": patch ---- - -better support for coexistence with older libraries (e.g. MooTools & Prototype.js) which modify the in-built `Array.from` function diff --git a/.changeset/fair-ducks-clean.md b/.changeset/fair-ducks-clean.md deleted file mode 100644 index 19269db760..0000000000 --- a/.changeset/fair-ducks-clean.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"rrweb-snapshot": patch -"rrweb": patch ---- - -Fix and test for bug #1457 which was affecting replay of complex tailwind css From aaee87499109fef069ec4924afc127bda2886bfc Mon Sep 17 00:00:00 2001 From: Jesse Wang Date: Mon, 24 Jun 2024 11:19:19 -0700 Subject: [PATCH 6/7] AMP-99342: Add old changeset --- .changeset/fair-ducks-clean.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fair-ducks-clean.md diff --git a/.changeset/fair-ducks-clean.md b/.changeset/fair-ducks-clean.md new file mode 100644 index 0000000000..e2117ea664 --- /dev/null +++ b/.changeset/fair-ducks-clean.md @@ -0,0 +1,5 @@ +--- +'@amplitude/rrweb': patch +--- + +Fix and test for bug #1457 which was affecting replay of complex tailwind css \ No newline at end of file From 54f236742da20b98f2125a09de0238e1a3016ad6 Mon Sep 17 00:00:00 2001 From: jxiwang Date: Mon, 24 Jun 2024 18:20:31 +0000 Subject: [PATCH 7/7] Apply formatting changes --- .changeset/fair-ducks-clean.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/fair-ducks-clean.md b/.changeset/fair-ducks-clean.md index e2117ea664..3f65a2b8bc 100644 --- a/.changeset/fair-ducks-clean.md +++ b/.changeset/fair-ducks-clean.md @@ -2,4 +2,4 @@ '@amplitude/rrweb': patch --- -Fix and test for bug #1457 which was affecting replay of complex tailwind css \ No newline at end of file +Fix and test for bug #1457 which was affecting replay of complex tailwind css