From c0241086b7a3a6f40ca709449b3d9f7dd32bef90 Mon Sep 17 00:00:00 2001 From: npt-1707 Date: Mon, 4 May 2026 07:20:34 +0800 Subject: [PATCH] public/libs/bootstrap/js/bootstrap.js: Fix XSS --- public/libs/bootstrap/js/bootstrap.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/public/libs/bootstrap/js/bootstrap.js b/public/libs/bootstrap/js/bootstrap.js index 87fa5b4eb0..28dbe4854a 100644 --- a/public/libs/bootstrap/js/bootstrap.js +++ b/public/libs/bootstrap/js/bootstrap.js @@ -98,7 +98,7 @@ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } - $parent = $(selector) + $parent = $(document).find(selector) e && e.preventDefault() @@ -439,10 +439,17 @@ * ================= */ $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { - var $this = $(this), href - , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 - , options = $.extend({}, $target.data(), $this.data()) - , slideIndex + var $this = $(this) + var href = $this.attr('href') + if (href) { + href = href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 + } + + var target = $this.attr('data-target') || href + var $target = $(document).find(target) + + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex $target.carousel(options) @@ -725,7 +732,7 @@ selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } - $parent = selector && $(selector) + $parent = selector && $(document).find(selector) if (!$parent || !$parent.length) $parent = $this.parent() @@ -990,8 +997,11 @@ $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { var $this = $(this) , href = $this.attr('href') - , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 - , option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) + var target = $this.attr('data-target') || + (href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 + + var $target = $(document).find(target) + var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) e.preventDefault()