Fix HTML parsing bug when </script> is in the phantomas results json

This commit is contained in:
Gaël Métais
2014-09-09 11:19:51 +02:00
parent 8f152c11a9
commit 2b86a5fdc6
+6 -1
View File
@@ -34,9 +34,14 @@ var resultsController = function(req, res, googleAnalyticsId) {
return res.status(404).send('Sorry, test not found...');
}
// Escape "</script>" because it can interfer with the HTML parser
var phantomasResults = results.phantomasResults;
phantomasResults = phantomasResults.replace('</script>', '\\u003c/script>');
var html = results.htmlTemplate;
html = html.replace('%%METADATA%%', results.phantomasMetadata);
html = html.replace('%%RESULTS%%', results.phantomasResults);
html = html.replace('%%RESULTS%%', phantomasResults);
html = html.replace('%%GA_ID%%', googleAnalyticsId);
res.setHeader('Content-Type', 'text/html');