From a90706dcf4edc9db86637596fe44478250c5542a Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Wed, 26 Sep 2018 18:03:42 +0530 Subject: [PATCH] [build] --- browser/index.js | 19 ++++++++++--------- es5/reporters/xunit.js | 19 ++++++++++--------- package.json | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/browser/index.js b/browser/index.js index cd0b565..4f44354 100644 --- a/browser/index.js +++ b/browser/index.js @@ -2442,6 +2442,10 @@ function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.itera var _require9 = require('../util/nodeutils'), clear = _require9.clear; + var escapeXML = function escapeXML(str) { + return str.replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>'); + }; + var toJSON = function toJSON(resultsArray) { return { testsuites: resultsArray.map(function (results) { @@ -2453,7 +2457,7 @@ function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.itera return { name: 'testsuite', attrs: { - name: name, + name: escapeXML(name), tests: count, success: success.length, failures: failures.length, @@ -2463,20 +2467,17 @@ function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.itera }, children: results.reduce(function (acc, r) { var reason = r.reason ? r.reason.stack || r.reason : ''; - var content = r.status !== 'ok' && r.status === 'skip' ? { - name: 'skipped', - text: reason - } : { - name: 'failure', - text: reason + var content = r.status !== 'ok' && { + name: r.status === 'skip' ? 'skipped' : 'failure', + text: escapeXML(reason) }; acc.push(_objectSpread({ name: 'testcase', attrs: { - name: r.description, + name: escapeXML(r.description), time: r.duration / 1000 || 0 } - }, _typeof2(content) === 'object' && content, _typeof2(content) === 'object' && { + }, _typeof2(content) === 'object' && { children: [content] })); return acc; diff --git a/es5/reporters/xunit.js b/es5/reporters/xunit.js index a55fcc5..cce4be6 100644 --- a/es5/reporters/xunit.js +++ b/es5/reporters/xunit.js @@ -11,6 +11,10 @@ var toXML = require('jsontoxml'); var _require = require('../util/nodeutils'), clear = _require.clear; +var escapeXML = function escapeXML(str) { + return str.replace(/&/g, '&').replace(/"/g, '"').replace(//g, '>'); +}; + var toJSON = function toJSON(resultsArray) { return { testsuites: resultsArray.map(function (results) { @@ -22,7 +26,7 @@ var toJSON = function toJSON(resultsArray) { return { name: 'testsuite', attrs: { - name: name, + name: escapeXML(name), tests: count, success: success.length, failures: failures.length, @@ -32,20 +36,17 @@ var toJSON = function toJSON(resultsArray) { }, children: results.reduce(function (acc, r) { var reason = r.reason ? r.reason.stack || r.reason : ''; - var content = r.status !== 'ok' && r.status === 'skip' ? { - name: 'skipped', - text: reason - } : { - name: 'failure', - text: reason + var content = r.status !== 'ok' && { + name: r.status === 'skip' ? 'skipped' : 'failure', + text: escapeXML(reason) }; acc.push(_objectSpread({ name: 'testcase', attrs: { - name: r.description, + name: escapeXML(r.description), time: r.duration / 1000 || 0 } - }, _typeof(content) === 'object' && content, _typeof(content) === 'object' && { + }, _typeof(content) === 'object' && { children: [content] })); return acc; diff --git a/package.json b/package.json index 706bc45..2552a79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@klenty/gunner", - "version": "0.11.10", + "version": "0.11.11", "description": "Zero magic, fast test-runner and assertion framework. No magic globals.", "main": "index.js", "repository": {