Skip to content
Open
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
12 changes: 6 additions & 6 deletions src/css/PropertyValuePart.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function PropertyValuePart(text, line, col, optionalHint) {
this.saturation = Number(RegExp.$2) / 100;
this.lightness = Number(RegExp.$3) / 100;
this.alpha = Number(RegExp.$4);
} else if (/^url\(("([^\\"]|\.)*")\)/i.test(text)) { // URI
} else if (/^url\(("([^\\"]|\\.)*")\)/i.test(text)) { // URI
// generated by TokenStream.readURI, so always double-quoted.
this.type = "uri";
this.uri = PropertyValuePart.parseString(RegExp.$1);
Expand Down Expand Up @@ -214,14 +214,14 @@ PropertyValuePart.parseString = function(str) {
* Helper method to serialize a CSS string.
*/
PropertyValuePart.serializeString = function(value) {
var replacer = function(match, c) {
if (c === "\"") {
return "\\" + c;
var replacer = function(match) {
if (match === "\"") {
return "\\" + match;
}
var cp = String.codePointAt ? String.codePointAt(0) :
var cp = match.codePointAt ? match.codePointAt(0) :
// We only escape non-surrogate chars, so using charCodeAt
// is harmless here.
String.charCodeAt(0);
match.charCodeAt(0);
return "\\" + cp.toString(16) + " ";
};
return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
Expand Down
11 changes: 10 additions & 1 deletion tests/css/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,16 @@ var YUITest = require("yuitest"),
Assert.areEqual("https://yahoo.com", result.parts[0].uri);
},

testURIValue5: function() {
var parser = new Parser({ strict:true });
var result = parser.parsePropertyValue("url(url_with_\\\".png)");

Assert.isInstanceOf(parserlib.css.PropertyValue, result);
Assert.areEqual(1, result.parts.length);
Assert.areEqual("uri", result.parts[0].type);
Assert.areEqual("url_with_\".png", result.parts[0].uri);
},

testStringValue: function() {
var parser = new Parser();
var result = parser.parsePropertyValue("'Hello world!'");
Expand Down Expand Up @@ -1373,7 +1383,6 @@ var YUITest = require("yuitest"),
Assert.areEqual("serif", result.parts[7].value);
}


}));

suite.add(new YUITest.TestCase({
Expand Down