From 001e45cd20629d968be9deed6256a956f9a22399 Mon Sep 17 00:00:00 2001 From: npt-1707 Date: Fri, 8 May 2026 10:50:56 +0800 Subject: [PATCH] web/assets/js/bootstrap.js: fix XSS --- web/assets/js/bootstrap.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/web/assets/js/bootstrap.js b/web/assets/js/bootstrap.js index 643e71cd..7136179f 100644 --- a/web/assets/js/bootstrap.js +++ b/web/assets/js/bootstrap.js @@ -100,7 +100,7 @@ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 } - $parent = $(selector) + $parent = $(document).find(selector) e && e.preventDefault() @@ -451,10 +451,16 @@ * ================= */ $(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) @@ -756,7 +762,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() @@ -1034,8 +1040,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()