Skip to content

Commit e50fc08

Browse files
authored
Merge pull request rrweb-io#27 from amplitude/AMP-105355
AMP-105355
2 parents fb075f1 + 69fe681 commit e50fc08

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

.changeset/no-neg-lookbehind.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@amplitude/rrweb-snapshot': patch
3+
'@amplitude/rrweb': patch
4+
---
5+
6+
Replay: Replace negative lookbehind in regexes from css parser as it causes issues with Safari 16
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@amplitude/rrweb': patch
3+
---
4+
5+
Return early for child same origin frames

packages/rrweb-snapshot/src/css.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
424424
* Parse selector.
425425
*/
426426

427+
// originally from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1
428+
const selectorMatcher = new RegExp(
429+
'^((' +
430+
[
431+
/[^\\]"(?:\\"|[^"])*"/.source, // consume any quoted parts (checking that the double quote isn't itself escaped)
432+
/[^\\]'(?:\\'|[^'])*'/.source, // same but for single quotes
433+
'[^{]',
434+
].join('|') +
435+
')+)',
436+
);
437+
427438
function selector() {
428439
whitespace();
429440
while (css[0] == '}') {
@@ -432,8 +443,7 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
432443
whitespace();
433444
}
434445

435-
// Use match logic from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1
436-
const m = match(/^(((?<!\\)"(?:\\"|[^"])*"|(?<!\\)'(?:\\'|[^'])*'|[^{])+)/);
446+
const m = match(selectorMatcher);
437447
if (!m) {
438448
return;
439449
}
@@ -869,8 +879,8 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
869879
name +
870880
'\\s*((?:' +
871881
[
872-
'(?<!\\\\)"(?:\\\\"|[^"])*"',
873-
"(?<!\\\\)'(?:\\\\'|[^'])*'",
882+
/[^\\]"(?:\\"|[^"])*"/.source, // consume any quoted parts (checking that the double quote isn't itself escaped)
883+
/[^\\]'(?:\\'|[^'])*'/.source, // same but for single quotes
874884
'[^;]',
875885
].join('|') +
876886
')+);',

0 commit comments

Comments
 (0)