From d573a7b7b752afa7d037ef3008991c176f39cbd8 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 19 Aug 2015 09:50:33 +0200 Subject: [PATCH] SONAR-6576 fix parsing of "<" and ">" characters --- .../helpers/code-with-issue-locations-helper.js | 2 +- .../test/unit/code-with-issue-locations-helper.spec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js index fd5d56a3bde..eed0d5f26d4 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js +++ b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js @@ -92,7 +92,7 @@ define(function () { */ function generateHTML (tokens) { return tokens.map(function (token) { - return '' + token.text + ''; + return '' + _.escape(token.text) + ''; }).join(''); } diff --git a/server/sonar-web/test/unit/code-with-issue-locations-helper.spec.js b/server/sonar-web/test/unit/code-with-issue-locations-helper.spec.js index a1fa2cb0a1e..7c3938c2d86 100644 --- a/server/sonar-web/test/unit/code-with-issue-locations-helper.spec.js +++ b/server/sonar-web/test/unit/code-with-issue-locations-helper.spec.js @@ -51,6 +51,12 @@ define(function (require) { ' * Copyright (C) 2008-2014 SonarSource'); // * Copyright (C) 2008-204 SonarSource }); + + bdd.it('should parse line with < and >', function () { + var code = '#include <stdio.h>', + result = helper(code, []); + assert.equal(result, '#include <stdio.h>'); + }); }); }); -- 2.39.5