mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 14:02:41 +00:00
Remove console.log slowing things down.
This commit is contained in:
@@ -19,12 +19,11 @@ renderer.link = function (href, title, text) {
|
|||||||
self = true;
|
self = true;
|
||||||
}
|
}
|
||||||
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
|
||||||
console.log(href);
|
|
||||||
console.log(this.options.sanitize);
|
|
||||||
if(href === null) {
|
if(href === null) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
let out = `<a href="${href}"`;
|
let out = `<a href="${escape(href)}"`;
|
||||||
if(title) {
|
if(title) {
|
||||||
out += ` title="${title}"`;
|
out += ` title="${title}"`;
|
||||||
}
|
}
|
||||||
@@ -32,7 +31,6 @@ renderer.link = function (href, title, text) {
|
|||||||
out += ' target="_self"';
|
out += ' target="_self"';
|
||||||
}
|
}
|
||||||
out += `>${text}</a>`;
|
out += `>${text}</a>`;
|
||||||
console.log(out);
|
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,6 +57,32 @@ const cleanUrl = function (sanitize, base, href) {
|
|||||||
return href;
|
return href;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const escapeTest = /[&<>"']/;
|
||||||
|
const escapeReplace = /[&<>"']/g;
|
||||||
|
const escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
|
||||||
|
const escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
|
||||||
|
const escapeReplacements = {
|
||||||
|
'&' : '&',
|
||||||
|
'<' : '<',
|
||||||
|
'>' : '>',
|
||||||
|
'"' : '"',
|
||||||
|
'\'' : '''
|
||||||
|
};
|
||||||
|
const getEscapeReplacement = (ch)=>escapeReplacements[ch];
|
||||||
|
const escape = function (html, encode) {
|
||||||
|
if(encode) {
|
||||||
|
if(escapeTest.test(html)) {
|
||||||
|
return html.replace(escapeReplace, getEscapeReplacement);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(escapeTestNoEncode.test(html)) {
|
||||||
|
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
};
|
||||||
|
|
||||||
const sanatizeScriptTags = (content)=>{
|
const sanatizeScriptTags = (content)=>{
|
||||||
return content
|
return content
|
||||||
.replace(/<script/ig, '<script')
|
.replace(/<script/ig, '<script')
|
||||||
|
|||||||
Reference in New Issue
Block a user