mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1226543 - fix URL quoting in CSSFilterEditorWidget.getValueAt. r=pbrosset
This commit is contained in:
parent
22d991e920
commit
a6f25acb9d
@ -6,7 +6,24 @@
|
|||||||
// Tests that the Filter Editor Widget parses filter values correctly (setCssValue)
|
// Tests that the Filter Editor Widget parses filter values correctly (setCssValue)
|
||||||
|
|
||||||
const TEST_URI = "chrome://devtools/content/shared/widgets/filter-frame.xhtml";
|
const TEST_URI = "chrome://devtools/content/shared/widgets/filter-frame.xhtml";
|
||||||
const {CSSFilterEditorWidget} = require("devtools/client/shared/widgets/FilterWidget");
|
const {CSSFilterEditorWidget} =
|
||||||
|
require("devtools/client/shared/widgets/FilterWidget");
|
||||||
|
const {cssTokenizer} = require("devtools/client/shared/css-parsing-utils");
|
||||||
|
const DOMUtils =
|
||||||
|
Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
|
||||||
|
|
||||||
|
// Verify that the given string consists of a valid CSS URL token.
|
||||||
|
// Return true on success, false on error.
|
||||||
|
function verifyURL(string) {
|
||||||
|
let lexer = DOMUtils.getCSSLexer(string);
|
||||||
|
|
||||||
|
let token = lexer.nextToken();
|
||||||
|
if (!token || token.tokenType !== "url") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lexer.nextToken() === null;
|
||||||
|
}
|
||||||
|
|
||||||
add_task(function *() {
|
add_task(function *() {
|
||||||
yield addTab("about:blank");
|
yield addTab("about:blank");
|
||||||
@ -80,8 +97,18 @@ add_task(function *() {
|
|||||||
widget.setCssValue("url(ordinary)");
|
widget.setCssValue("url(ordinary)");
|
||||||
is(widget.getCssValue(), "url(ordinary)",
|
is(widget.getCssValue(), "url(ordinary)",
|
||||||
"setCssValue should not quote ordinary unquoted URL contents");
|
"setCssValue should not quote ordinary unquoted URL contents");
|
||||||
widget.setCssValue("url(invalid\\ \\)\\ \\{\\ when\\ \\}\\ \\;\\ unquoted)");
|
|
||||||
is(widget.getCssValue(),
|
let quotedurl =
|
||||||
"url(invalid\\ \\)\\ \\{\\ when\\ \\}\\ \\;\\ unquoted)",
|
"url(invalid\\ \\)\\ {\\\twhen\\ }\\ ;\\ \\\\unquoted\\'\\\")";
|
||||||
|
ok(verifyURL(quotedurl), "weird URL is valid");
|
||||||
|
widget.setCssValue(quotedurl);
|
||||||
|
is(widget.getCssValue(), quotedurl,
|
||||||
"setCssValue should re-quote weird unquoted URL contents");
|
"setCssValue should re-quote weird unquoted URL contents");
|
||||||
|
|
||||||
|
let dataurl = "url(data:image/svg+xml;utf8,<svg\\ " +
|
||||||
|
"xmlns=\\\"http://www.w3.org/2000/svg\\\"><filter\\ id=\\\"blur\\\">" +
|
||||||
|
"<feGaussianBlur\\ stdDeviation=\\\"3\\\"/></filter></svg>#blur)";
|
||||||
|
ok(verifyURL(dataurl), "data URL is valid");
|
||||||
|
widget.setCssValue(dataurl);
|
||||||
|
is(widget.getCssValue(), dataurl, "setCssValue should not mangle data urls");
|
||||||
});
|
});
|
||||||
|
@ -828,7 +828,7 @@ CSSFilterEditorWidget.prototype = {
|
|||||||
// Unquoted. This approach might change the original input -- for
|
// Unquoted. This approach might change the original input -- for
|
||||||
// example the original might be over-quoted. But, this is
|
// example the original might be over-quoted. But, this is
|
||||||
// correct and probably good enough.
|
// correct and probably good enough.
|
||||||
return filter.value.replace(/[ \t(){};]/g, "\\$&");
|
return filter.value.replace(/[\\ \t()"']/g, "\\$&");
|
||||||
},
|
},
|
||||||
|
|
||||||
removeAt: function(index) {
|
removeAt: function(index) {
|
||||||
|
Loading…
Reference in New Issue
Block a user