浏览代码

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

Gaël Métais 10 年之前
父节点
当前提交
2b86a5fdc6
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      app/node_controllers/resultsController.js

+ 6 - 1
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 "</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');