var URL_PREFIX = 'url(';
var UPPERCASE_URL_PREFIX = 'URL(';
var URL_SUFFIX = ')';
+var SINGLE_QUOTE_URL_SUFFIX = '\')';
+var DOUBLE_QUOTE_URL_SUFFIX = '")';
var DATA_URI_PREFIX_PATTERN = /^\s*['"]?\s*data:/;
var DATA_URI_TRAILER_PATTERN = /[\s\};,\/!]/;
if (nextStart == -1 && nextStartUpperCase > -1)
nextStart = nextStartUpperCase;
- isDataURI = DATA_URI_PREFIX_PATTERN.test(data.substring(nextStart + URL_PREFIX.length));
+ if (data[nextStart + URL_PREFIX.length] == '"') {
+ nextEnd = data.indexOf(DOUBLE_QUOTE_URL_SUFFIX, nextStart);
+ } else if (data[nextStart + URL_PREFIX.length] == '\'') {
+ nextEnd = data.indexOf(SINGLE_QUOTE_URL_SUFFIX, nextStart);
+ } else {
+ isDataURI = DATA_URI_PREFIX_PATTERN.test(data.substring(nextStart + URL_PREFIX.length));
- if (isDataURI) {
- firstMatch = split(data.substring(nextStart), DATA_URI_TRAILER_PATTERN, false, '(', ')', true).pop();
+ if (isDataURI) {
+ firstMatch = split(data.substring(nextStart), DATA_URI_TRAILER_PATTERN, false, '(', ')', true).pop();
- if (firstMatch && firstMatch[firstMatch.length - 1] == URL_SUFFIX) {
- nextEnd = nextStart + firstMatch.length - URL_SUFFIX.length;
- } else {
- nextEnd = -1;
- }
- } else {
- if (data[nextStart + URL_PREFIX.length] == '"') {
- nextEnd = data.indexOf('"', nextStart + URL_PREFIX.length + 1);
- } else if (data[nextStart + URL_PREFIX.length] == '\'') {
- nextEnd = data.indexOf('\'', nextStart + URL_PREFIX.length + 1);
+ if (firstMatch && firstMatch[firstMatch.length - 1] == URL_SUFFIX) {
+ nextEnd = nextStart + firstMatch.length - URL_SUFFIX.length;
+ } else {
+ nextEnd = -1;
+ }
} else {
nextEnd = data.indexOf(URL_SUFFIX, nextStart);
}
'.a{cursor:url("data:application/octet-stream;base64,A...rotate(30 60,60)...="),move!important}.b{cursor:url("data:application/octet-stream;base64,A...rotate(30 60,60)...=")}',
'.a{cursor:__ESCAPED_URL_CLEAN_CSS0__,move!important}.b{cursor:__ESCAPED_URL_CLEAN_CSS0__}',
'.a{cursor:url("data:application/octet-stream;base64,A...rotate(30 60,60)...="),move!important}.b{cursor:url("data:application/octet-stream;base64,A...rotate(30 60,60)...=")}',
+ ],
+ 'quoted data URI with unbalanced closing brackets': [
+ '.a{cursor:url("data:application/octet-stream;base64,A...%3C!--)--%3E...=");color:red;}',
+ '.a{cursor:__ESCAPED_URL_CLEAN_CSS0__;color:red;}',
+ '.a{cursor:url("data:application/octet-stream;base64,A...%3C!--)--%3E...=");color:red;}'
]
})
)