From 2b86a5fdc696208bf4a38f2a960935e0f6a87ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20M=C3=A9tais?= Date: Tue, 9 Sep 2014 11:19:51 +0200 Subject: [PATCH] Fix HTML parsing bug when is in the phantomas results json --- app/node_controllers/resultsController.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/node_controllers/resultsController.js b/app/node_controllers/resultsController.js index de3b122..9c135a1 100644 --- a/app/node_controllers/resultsController.js +++ b/app/node_controllers/resultsController.js @@ -34,9 +34,14 @@ var resultsController = function(req, res, googleAnalyticsId) { return res.status(404).send('Sorry, test not found...'); } + // Escape "" because it can interfer with the HTML parser + var phantomasResults = results.phantomasResults; + phantomasResults = phantomasResults.replace('', '\\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');