Skip to content

Commit 559231a

Browse files
committed
Fix unquoted url's, remove special handling of data. Fixes less#733
1 parent 3031517 commit 559231a

File tree

4 files changed

+7
-28
lines changed

4 files changed

+7
-28
lines changed

lib/less/parser.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -642,28 +642,14 @@ less.Parser = function Parser(env) {
642642

643643
if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
644644
value = $(this.entities.quoted) || $(this.entities.variable) ||
645-
$(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || "";
645+
$(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || "";
646646

647647
expect(')');
648648

649-
return new(tree.URL)((value.value != null || value.data || value instanceof tree.Variable)
649+
return new(tree.URL)((value.value != null || value instanceof tree.Variable)
650650
? value : new(tree.Anonymous)(value), imports.paths);
651651
},
652652

653-
dataURI: function () {
654-
var obj;
655-
656-
if ($(/^data:/)) {
657-
obj = {};
658-
obj.mime = $(/^[^\/]+\/[^,;)]+/) || '';
659-
obj.charset = $(/^;\s*charset=[^,;)]+/) || '';
660-
obj.base64 = $(/^;\s*base64/) || '';
661-
obj.data = $(/^,\s*[^)]+/);
662-
663-
if (obj.data) { return obj }
664-
}
665-
},
666-
667653
//
668654
// A Variable entity, such as `@fink`, in
669655
//

lib/less/tree/url.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
(function (tree) {
22

33
tree.URL = function (val, paths) {
4-
if (val.data) {
5-
this.attrs = val;
6-
} else {
7-
this.value = val;
8-
this.paths = paths;
9-
}
4+
this.value = val;
5+
this.paths = paths;
106
};
117
tree.URL.prototype = {
128
toCSS: function () {
13-
return "url(" + (this.attrs ? 'data:' + this.attrs.mime + this.attrs.charset + this.attrs.base64 + this.attrs.data
14-
: this.value.toCSS()) + ")";
9+
return "url(" + this.value.toCSS() + ")";
1510
},
1611
eval: function (ctx) {
17-
if (this.attrs) {
18-
return this;
19-
}
20-
2112
var val = this.value.eval(ctx);
2213

2314
// Add the base path if the URL is relative and we are in the browser

test/css/css.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ p + h1 {
8484
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
8585
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
8686
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
87+
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
8788
}
8889
#svg-data-uri {
8990
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');

test/less/css.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ p + h1 {
9494
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
9595
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
9696
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
97+
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
9798
}
9899

99100
#svg-data-uri {

0 commit comments

Comments
 (0)