diff --git a/common.mjs b/common.mjs
index 0605665..a5f26b0 100644
--- a/common.mjs
+++ b/common.mjs
@@ -55,7 +55,7 @@ export default async function(
const Properties = new Map([
["html-title", (article, singleLine, document) =>
- `
${escapeHTML(Properties.get("title")(article, singleLine, document), document)}
`
+ `${escapeHTML(Properties.get("title")(article, singleLine, document))}
`
],
["title", (article, singleLine) =>
singleLine ? article.title.replace(/\n+/gm, ' ') : article.title
@@ -398,11 +398,16 @@ export default async function(
- //Taken from https://stackoverflow.com/a/22706073/5701177
- function escapeHTML(string, document) {
- const p = document.createElement("p");
- p.appendChild(document.createTextNode(string));
- return p.innerHTML;
+ //Taken from https://stackoverflow.com/a/30970751
+ function escapeHTML(string) {
+ const lookup = {
+ '&': "&",
+ '"': """,
+ '\'': "'",
+ '<': "<",
+ '>': ">"
+ };
+ return string.replace( /[&"'<>]/g, c => lookup[c] );
}
async function getHTML(document, window) {
@@ -489,7 +494,7 @@ export default async function(
`);
}
writeStream.write(`
- ${escapeHTML(Properties.get("title")(article, false, document), document)}
+ ${escapeHTML(Properties.get("title")(article, false, document))}
`
);
@@ -508,12 +513,12 @@ export default async function(
writeStream.write(`