[scraper] add html entities escape

This commit is contained in:
TheBeastLT
2020-03-14 22:54:44 +01:00
parent dbb3794c5f
commit 3ca4479d8a
3 changed files with 14 additions and 5 deletions

View File

@@ -80,6 +80,14 @@ function escapeTitle(title) {
.trim();
}
function escapeHTML(title) {
return title
.replace(/'|'/g, '\'')
.replace(/&|&/g, '&')
.replace(/!/g, '!')
.replace(/%/g, '%');
}
async function getImdbId(info, type) {
const name = escapeTitle(info.title);
const year = info.year || info.date && info.date.slice(0, 4);
@@ -121,4 +129,4 @@ async function getKitsuId(info) {
}));
}
module.exports = { getMetadata, getImdbId, getKitsuId };
module.exports = { getMetadata, getImdbId, getKitsuId, escapeHTML };