summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Carver2018-09-12 20:56:14 (GMT)
committerMark Carver2018-09-12 20:56:14 (GMT)
commita68edd11861555119cf97a412405dffe8526437d (patch)
treea3c8b4c70b80bfe0b5f70d61a6901f5cf4ec2f9d
parent295bf67cb592c263219b8b2a2f49a276e283bdad (diff)
Issue #2999163 by markcarver, Gomez_in_the_South: XSS vulnerability in modal.js
Signed-off-by: Mark Carver <mark.carver@me.com>
-rw-r--r--js/modal.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/js/modal.js b/js/modal.js
index 5bcce17..d7dabcf 100644
--- a/js/modal.js
+++ b/js/modal.js
@@ -6,6 +6,13 @@
'use strict';
/**
+ * Document jQuery object.
+ *
+ * @type {jQuery}
+ */
+ var $document = $(document);
+
+ /**
* Only process this once.
*/
Bootstrap.once('modal', function (settings) {
@@ -131,12 +138,13 @@
// Replace the data API so that it calls $.fn.modal rather than Plugin.
// This allows sub-themes to replace the jQuery Plugin if they like with
// out having to redo all this boilerplate.
- $(document)
+ $document
.off('click.bs.modal.data-api')
.on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this);
var href = $this.attr('href');
- var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))); // strip for ie7
+ var target = $this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')); // strip for ie7
+ var $target = $document.find(target);
var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
if ($this.is('a')) e.preventDefault();