Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No neg lookbehind #1493

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/no-neg-lookbehind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"rrweb-snapshot": patch
"rrweb": patch
---

Replay: Replace negative lookbehind in regexes from css parser as it causes issues with Safari 16
2 changes: 1 addition & 1 deletion .changeset/silent-plants-perform.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'rrweb': patch
"rrweb": patch
---

Return early for child same origin frames
18 changes: 14 additions & 4 deletions packages/rrweb-snapshot/src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
* Parse selector.
*/

// originally from https://github.com/NxtChg/pieces/blob/3eb39c8287a97632e9347a24f333d52d916bc816/js/css_parser/css_parse.js#L46C1-L47C1
const selectorMatcher = new RegExp(
'^((' +
[
/[^\\]"(?:\\"|[^"])*"/.source, // consume any quoted parts (checking that the double quote isn't itself escaped)
/[^\\]'(?:\\'|[^'])*'/.source, // same but for single quotes
'[^{]',
].join('|') +
')+)',
);

function selector() {
whitespace();
while (css[0] == '}') {
Expand All @@ -432,8 +443,7 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
whitespace();
}

// 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(selectorMatcher);
if (!m) {
return;
}
Expand Down Expand Up @@ -869,8 +879,8 @@ export function parse(css: string, options: ParserOptions = {}): Stylesheet {
name +
'\\s*((?:' +
[
'(?<!\\\\)"(?:\\\\"|[^"])*"',
"(?<!\\\\)'(?:\\\\'|[^'])*'",
/[^\\]"(?:\\"|[^"])*"/.source, // consume any quoted parts (checking that the double quote isn't itself escaped)
/[^\\]'(?:\\'|[^'])*'/.source, // same but for single quotes
'[^;]',
].join('|') +
')+);',
Expand Down
Loading