From bcad4bcb5f5a9ef079b2883a48a698b35261e083 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 25 Aug 2017 21:54:49 +0200 Subject: Fix XSS in data-target --- js/src/util.js | 2 +- js/tests/visual/modal.html | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/src/util.js b/js/src/util.js index 69fb8283c..cd3f1fb6a 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -117,7 +117,7 @@ const Util = (($) => { } try { - const $selector = $(selector) + const $selector = $(document).find(selector) return $selector.length > 0 ? selector : null } catch (error) { return null diff --git a/js/tests/visual/modal.html b/js/tests/visual/modal.html index c9a950b8c..da9bbf93a 100644 --- a/js/tests/visual/modal.html +++ b/js/tests/visual/modal.html @@ -167,6 +167,10 @@ + + -- cgit v1.2.3 From 9612830701211d757ff95ceccbb494fd2e7ee17e Mon Sep 17 00:00:00 2001 From: meeque Date: Fri, 25 Aug 2017 22:53:15 +0200 Subject: Add unit test for xss in data target attribute --- js/tests/unit/modal.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'js') diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 3b028dc10..5b265df15 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -597,4 +597,40 @@ $(function () { }) .trigger('click') }) + + QUnit.test('should not parse target as html', function (assert) { + assert.expect(1) + var done = assert.async() + + var $toggleBtn = $('