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

fix(rrweb-snapshot): don't exclude @import CSS rules from the output when an exception is thrown #720

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

hvpavel
Copy link
Contributor

@hvpavel hvpavel commented Oct 5, 2021

Do not exclude @import CSS rules from the output when an exception is thrown and use CSSRule.cssText instead.

rrweb-snapshot throws a SecurityError exception when parses @import CSS rules, that point out to an external domain and are declared within a CSS file.

page.html:

<link rel="stylesheet" href="styles.css" />

styles.css:

/* this rule will be excluded from rrweb-snapshot output */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');

The fix is meant to fix this problem and keep the original CSS line if another issue happens while serializing an @import CSS rule.

A repository with an example of the issue: https://github.com/hvpavel/rrweb-snapshot-css-import-issue.

…and use CSSRule.cssText instead when they throw an exception while accessing their CSSStyleSheet.cssRules property
@Yuyz0112
Copy link
Member

Yuyz0112 commented Oct 6, 2021

Thanks!

@Yuyz0112 Yuyz0112 merged commit 4ff6e41 into rrweb-io:master Oct 6, 2021
@hvpavel
Copy link
Contributor Author

hvpavel commented Oct 6, 2021

@Yuyz0112 thanks for accepting the fix. Could you please tell me when you will be able to publish a package with the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants