diff --git a/src/webserver.js b/src/webserver.js index 86e1a830db..035e8ae0b3 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -94,21 +94,28 @@ var path = require('path'), browserTitle: meta.config.title || 'NodeBB', csrf: options.res.locals.csrf_token, relative_path: nconf.get('relative_path'), - meta_tags: metaString, - link_tags: linkTags, clientScripts: clientScripts, navigation: custom_header.navigation, 'cache-buster': meta.config['cache-buster'] ? 'v=' + meta.config['cache-buster'] : '', allowRegistration: meta.config.allowRegistration === undefined || parseInt(meta.config.allowRegistration, 10) === 1 + }, + escapeList = { + '&': '&', + '<': '<', + '>': '>', + "'": ''', + '"': '"' }; var uid = '0'; // Meta Tags - templateValues.meta_tags = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || [])).map(function(tag) { - tag.content = tag.content.replace('"', '"').replace("'", '''); + templateValues.meta_tags = utils.buildMetaTags(defaultMetaTags.concat(options.metaTags || []).map(function(tag) { + tag.content = tag.content.replace(/[&<>'"]/g, function(tag) { + return escapeList[tag] || tag; + }); return tag; - }); + })); templateValues.link_tags = utils.buildLinkTags(defaultLinkTags.concat(options.linkTags || [])); if(options.req.user && options.req.user.uid) {