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

when css property value has ";", it will get an error #3

Open
VicKun4937 opened this issue Jan 23, 2019 · 1 comment
Open

when css property value has ";", it will get an error #3

VicKun4937 opened this issue Jan 23, 2019 · 1 comment

Comments

@VicKun4937
Copy link

A css like below :
.test { background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAAC5JREFUKFNjGIKgvLz8P5RJPABpIlkjTBNJGpE1Ea2RZA0gQLIGECBZw2ACDAwAhS4mQZAuqGcAAAAASUVORK5CYII=); }
it will splite by ";"
It can be solve by code below:
var reg = new RegExp("image/png;base64", "g"); var regback = new RegExp("image/png+&+base64", "g");; var declarations = css.substring(lbracket + 1, rbracket).replace(reg, "image/png+&+base64") .split(";") .map(function(declaration){ return declaration.trim().replace(regback, "image/png;base64"); }) .filter(function(declaration) { return declaration.length > 0; }); // Remove any empty ("") values from the array
I change the code in node models and it work well.

@gezakerecsenyi
Copy link

Agreed with the issue, but not with the solution. I think a more general solution would be to simply add string handling in the first place. There is no checking for strings, so for example putting input[value="{"] would break it. Implementation would also require handling of escaped strings.

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

No branches or pull requests

2 participants