Skip to content

Commit 71ababf

Browse files
committed
Fix Polymer#5693: CSS url parameter issue when it includes quotes
1 parent 10220c9 commit 71ababf

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/utils/resolve-url.js

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ export function resolveUrl(url, baseURI) {
7777
*/
7878
export function resolveCss(cssText, baseURI) {
7979
return cssText.replace(CSS_URL_RX, function(m, pre, url, post) {
80+
// No resolution for data: urls
81+
if (url.match(/^["']?data:/)) {
82+
return pre + url + post;
83+
}
8084
return pre + '\'' +
8185
resolveUrl(url.replace(/["']/g, ''), baseURI) +
8286
'\'' + post;

test/unit/resolveurl.html

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
:host {
3131
background: url('foo.png');
3232
}
33+
.inline-svg {
34+
background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><circle cx='5' cy='5' r='4'/></svg>");
35+
}
3336
</style>
3437
<img id="root" src$="[[rootPath]]foo.png">
3538
<img id="import" src$="[[importPath]]foo.png">
@@ -125,6 +128,7 @@
125128
var matchImport = /defineImport\//i;
126129
var style = el.shadowRoot.querySelector('style') || document.querySelector('style[scope=x-late]');
127130
assert.match(style.textContent, matchImport);
131+
assert.match(style.textContent, /url\("data:image\/svg\+xml;utf8,<svg xmlns='http:\/\/www.w3.org\/2000\/svg' width='10' height='10'><circle cx='5' cy='5' r='4'\/><\/svg>"\)/);
128132
assert.match(el.$.import.getAttribute('src'), matchImport);
129133
assert.match(el.$.root.getAttribute('src'), matchRoot);
130134
document.body.removeChild(el);

0 commit comments

Comments
 (0)