css2json icon indicating copy to clipboard operation
css2json copied to clipboard

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

Open VicKun4937 opened this issue 6 years ago • 1 comments

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.

VicKun4937 avatar Jan 23 '19 10:01 VicKun4937

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.

gezakerecsenyi avatar Oct 20 '19 20:10 gezakerecsenyi