-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: css syntax error: 'Unclosed string' #1735
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
base: master
Are you sure you want to change the base?
fix: css syntax error: 'Unclosed string' #1735
Conversation
🦋 Changeset detectedLatest commit: 9a9db7c The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
d0328dc to
5408907
Compare
packages/rrweb-snapshot/src/utils.ts
Outdated
|
|
||
| if (quickTestRegExp.test(cssStringified)) { | ||
| // Remove e.g. "border-top-style: ;" | ||
| const regex = /(?<=^|\{|\;)\s*[_a-zA-Z][_a-zA-Z0-9-]*:\s*;/gm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex breakdown:
- We should see "new line" or "{" or ";" before regex starts (which is precedes css rule name)
(?<=^|\{|\;) - Regex might start with empty symbols (between "new line / { / ;" and actual css rule name)
\s* - Then it matches css rule name
[_a-zA-Z][_a-zA-Z0-9-]* - After css rule name, there should be ":" symbol (between css rule name and its value)
: - Then it might have some empty symbols
\s* - Then its essential to end css rule, without any characters, which might be interpreted as css value
;
All occurrences of that regex are invalid css properties and have to be removed
| const quickTestRegExp = /:\s*;/; | ||
|
|
||
| if (quickTestRegExp.test(cssStringified)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug is rare, so it worth to check "if original css rules even has pattern of :\s*;"
If it hasn't, then we don't need to execute regex.
This will save some CPU cycles
5408907 to
9a9db7c
Compare
Fixes #1734