|
@@ -74,14 +74,14 @@
|
|
|
var ret = content.replace(URL_EXP, function(value) {
|
|
var ret = content.replace(URL_EXP, function(value) {
|
|
|
var result = value.match(URL_VALUE_EXP);
|
|
var result = value.match(URL_VALUE_EXP);
|
|
|
if (result)
|
|
if (result)
|
|
|
- if (!(result[1].indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (result[1].indexOf("data:") != 0)
|
|
|
return value.replace(result[1], formatURL(result[1], host));
|
|
return value.replace(result[1], formatURL(result[1], host));
|
|
|
return value;
|
|
return value;
|
|
|
});
|
|
});
|
|
|
return ret.replace(IMPORT_ALT_EXP, function(value) {
|
|
return ret.replace(IMPORT_ALT_EXP, function(value) {
|
|
|
var result = value.match(IMPORT_VALUE_ALT_EXP);
|
|
var result = value.match(IMPORT_VALUE_ALT_EXP);
|
|
|
if (result)
|
|
if (result)
|
|
|
- if (!(result[1].indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (result[1].indexOf("data:") != 0)
|
|
|
return "@import \"" + formatURL(result[1], host) + "\";";
|
|
return "@import \"" + formatURL(result[1], host) + "\";";
|
|
|
return value;
|
|
return value;
|
|
|
});
|
|
});
|
|
@@ -127,7 +127,7 @@
|
|
|
result = values[i].match(URL_VALUE_EXP);
|
|
result = values[i].match(URL_VALUE_EXP);
|
|
|
if (result && result[1]) {
|
|
if (result && result[1]) {
|
|
|
url = formatURL(result[1], host);
|
|
url = formatURL(result[1], host);
|
|
|
- if (!(url.indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (url.indexOf("data:") != 0)
|
|
|
sendRequest(result[1]);
|
|
sendRequest(result[1]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -138,7 +138,7 @@
|
|
|
function processStylesheets(doc, docElement, baseURI, requestManager) {
|
|
function processStylesheets(doc, docElement, baseURI, requestManager) {
|
|
|
Array.prototype.forEach.call(docElement.querySelectorAll('link[href][rel*="stylesheet"]'), function(node) {
|
|
Array.prototype.forEach.call(docElement.querySelectorAll('link[href][rel*="stylesheet"]'), function(node) {
|
|
|
var href = node.getAttribute("href"), fullHref = formatURL(href, baseURI);
|
|
var href = node.getAttribute("href"), fullHref = formatURL(href, baseURI);
|
|
|
- if (!(href.indexOf("data:") == 0)) {
|
|
|
|
|
|
|
+ if (href.indexOf("data:") != 0) {
|
|
|
requestManager.send(fullHref, function(data) {
|
|
requestManager.send(fullHref, function(data) {
|
|
|
var i, newNode, commentNode;
|
|
var i, newNode, commentNode;
|
|
|
if (data.status >= 400) {
|
|
if (data.status >= 400) {
|
|
@@ -180,7 +180,7 @@
|
|
|
result = imports[i].match(IMPORT_URL_VALUE_EXP);
|
|
result = imports[i].match(IMPORT_URL_VALUE_EXP);
|
|
|
if (result && (result[2] || result[4])) {
|
|
if (result && (result[2] || result[4])) {
|
|
|
url = formatURL(result[2] || result[4], styleSheet._baseURI || baseURI);
|
|
url = formatURL(result[2] || result[4], styleSheet._baseURI || baseURI);
|
|
|
- if (!(url.indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (url.indexOf("data:") != 0)
|
|
|
sendRequest(imports[i]);
|
|
sendRequest(imports[i]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -202,7 +202,7 @@
|
|
|
var url, value = node.getAttribute("background");
|
|
var url, value = node.getAttribute("background");
|
|
|
if (value.indexOf(".") != -1) {
|
|
if (value.indexOf(".") != -1) {
|
|
|
url = formatURL(value, baseURI);
|
|
url = formatURL(value, baseURI);
|
|
|
- if (!(url.indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (url.indexOf("data:") != 0)
|
|
|
requestManager.send(url, function(data) {
|
|
requestManager.send(url, function(data) {
|
|
|
node.setAttribute("background", getDataURI(data, EMPTY_PIXEL_DATA, true));
|
|
node.setAttribute("background", getDataURI(data, EMPTY_PIXEL_DATA, true));
|
|
|
}, "x-user-defined", "base64");
|
|
}, "x-user-defined", "base64");
|
|
@@ -228,7 +228,7 @@
|
|
|
function process(attributeName) {
|
|
function process(attributeName) {
|
|
|
Array.prototype.forEach.call(images, function(node) {
|
|
Array.prototype.forEach.call(images, function(node) {
|
|
|
var url = formatURL(node.getAttribute(attributeName), baseURI);
|
|
var url = formatURL(node.getAttribute(attributeName), baseURI);
|
|
|
- if (!(url.indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (url.indexOf("data:") != 0)
|
|
|
requestManager.send(url, function(data) {
|
|
requestManager.send(url, function(data) {
|
|
|
node.setAttribute(attributeName, getDataURI(data, EMPTY_PIXEL_DATA, true));
|
|
node.setAttribute(attributeName, getDataURI(data, EMPTY_PIXEL_DATA, true));
|
|
|
}, "x-user-defined", "base64");
|
|
}, "x-user-defined", "base64");
|
|
@@ -248,7 +248,7 @@
|
|
|
var images = docElement.querySelectorAll('object[type="image/svg+xml"], object[type="image/svg-xml"], embed[src*=".svg"]');
|
|
var images = docElement.querySelectorAll('object[type="image/svg+xml"], object[type="image/svg-xml"], embed[src*=".svg"]');
|
|
|
Array.prototype.forEach.call(images, function(node) {
|
|
Array.prototype.forEach.call(images, function(node) {
|
|
|
var data = node.getAttribute("data"), src = node.getAttribute("src"), url = formatURL(data || src, baseURI);
|
|
var data = node.getAttribute("data"), src = node.getAttribute("src"), url = formatURL(data || src, baseURI);
|
|
|
- if (!(url.indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (url.indexOf("data:") != 0)
|
|
|
requestManager.send(url, function(data) {
|
|
requestManager.send(url, function(data) {
|
|
|
node.setAttribute(data ? "data" : "src", getDataURI(data, "data:text/xml,<svg></svg>", true));
|
|
node.setAttribute(data ? "data" : "src", getDataURI(data, "data:text/xml,<svg></svg>", true));
|
|
|
}, null, null);
|
|
}, null, null);
|
|
@@ -266,7 +266,7 @@
|
|
|
function processScripts(docElement, baseURI, characterSet, requestManager) {
|
|
function processScripts(docElement, baseURI, characterSet, requestManager) {
|
|
|
Array.prototype.forEach.call(docElement.querySelectorAll("script[src]"), function(node) {
|
|
Array.prototype.forEach.call(docElement.querySelectorAll("script[src]"), function(node) {
|
|
|
var src = node.getAttribute("src");
|
|
var src = node.getAttribute("src");
|
|
|
- if (!(src.indexOf("data:") == 0))
|
|
|
|
|
|
|
+ if (src.indexOf("data:") != 0)
|
|
|
requestManager.send(formatURL(src, baseURI), function(data) {
|
|
requestManager.send(formatURL(src, baseURI), function(data) {
|
|
|
if (data.status < 400) {
|
|
if (data.status < 400) {
|
|
|
data.content = data.content.replace(/"([^"]*)<\/\s*script\s*>([^"]*)"/gi, '"$1<"+"/script>$2"');
|
|
data.content = data.content.replace(/"([^"]*)<\/\s*script\s*>([^"]*)"/gi, '"$1<"+"/script>$2"');
|