|
@@ -440,8 +440,8 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
this.doc.querySelectorAll("[href]").forEach(element => {
|
|
this.doc.querySelectorAll("[href]").forEach(element => {
|
|
|
if (element.href) {
|
|
if (element.href) {
|
|
|
const href = element.href.baseVal ? element.href.baseVal : element.href;
|
|
const href = element.href.baseVal ? element.href.baseVal : element.href;
|
|
|
- const match = href.match(/(.*)#.*$/);
|
|
|
|
|
- if (!match || match[1] != this.baseURI) {
|
|
|
|
|
|
|
+ const normalizedHref = DomUtil.normalizeURL(href);
|
|
|
|
|
+ if (!normalizedHref || normalizedHref != this.baseURI) {
|
|
|
element.setAttribute("href", href);
|
|
element.setAttribute("href", href);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -759,6 +759,12 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
// ---------
|
|
// ---------
|
|
|
// DomHelper
|
|
// DomHelper
|
|
|
// ---------
|
|
// ---------
|
|
|
|
|
+ const REGEXP_AMP = /&/g;
|
|
|
|
|
+ const REGEXP_NBSP = /\u00a0/g;
|
|
|
|
|
+ const REGEXP_START_TAG = /</g;
|
|
|
|
|
+ const REGEXP_END_TAG = />/g;
|
|
|
|
|
+ const REGEXP_URL_HASH = /(#.+?)$/;
|
|
|
|
|
+
|
|
|
class DomProcessorHelper {
|
|
class DomProcessorHelper {
|
|
|
static setFrameEmptySrc(frameElement) {
|
|
static setFrameEmptySrc(frameElement) {
|
|
|
if (frameElement.tagName == "OBJECT") {
|
|
if (frameElement.tagName == "OBJECT") {
|
|
@@ -840,7 +846,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
if (resourceURL.startsWith(DATA_URI_PREFIX)) {
|
|
if (resourceURL.startsWith(DATA_URI_PREFIX)) {
|
|
|
- const escapedResourceURL = resourceURL.replace(/&/g, "&").replace(/\u00a0/g, " ").replace(/</g, "<").replace(/>/g, ">");
|
|
|
|
|
|
|
+ const escapedResourceURL = resourceURL.replace(REGEXP_AMP, "&").replace(REGEXP_NBSP, " ").replace(REGEXP_START_TAG, "<").replace(REGEXP_END_TAG, ">");
|
|
|
if (escapedResourceURL != resourceURL && stylesheetContent.includes(urlFunction)) {
|
|
if (escapedResourceURL != resourceURL && stylesheetContent.includes(urlFunction)) {
|
|
|
stylesheetContent = stylesheetContent.replace(DomUtil.getRegExp(urlFunction), urlFunction.replace(originalResourceURL, escapedResourceURL));
|
|
stylesheetContent = stylesheetContent.replace(DomUtil.getRegExp(urlFunction), urlFunction.replace(originalResourceURL, escapedResourceURL));
|
|
|
}
|
|
}
|
|
@@ -914,7 +920,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
|
|
|
const DOMParser = DOM.getParser();
|
|
const DOMParser = DOM.getParser();
|
|
|
if (DOMParser) {
|
|
if (DOMParser) {
|
|
|
const svgDoc = new DOMParser().parseFromString(content, "image/svg+xml");
|
|
const svgDoc = new DOMParser().parseFromString(content, "image/svg+xml");
|
|
|
- const hashMatch = originalResourceURL.match(/(#.+?)$/);
|
|
|
|
|
|
|
+ const hashMatch = originalResourceURL.match(REGEXP_URL_HASH);
|
|
|
if (hashMatch && hashMatch[0]) {
|
|
if (hashMatch && hashMatch[0]) {
|
|
|
const symbolElement = svgDoc.querySelector(hashMatch[0]);
|
|
const symbolElement = svgDoc.querySelector(hashMatch[0]);
|
|
|
if (symbolElement) {
|
|
if (symbolElement) {
|