Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorNikon the Third <nikonthethird@gmx.at>2021-03-02 18:16:09 +0300
committerGitHub <noreply@github.com>2021-03-02 18:16:09 +0300
commit7ad0625b8d1e35f0843040602d6cbf124786fc51 (patch)
tree2df40ba7d9279e25f3537cbb70de01cbef4a494b /js/tests
parent8ec32eec44f46da2980d851e88523b8765e76bc8 (diff)
Adjust `SAFE_URL_PATTERN` regex for use with `test` method. (#33153)
The `test` method on regexes does not behave like `match` on strings for checks if the regex matches when the global modifier (g) is present. Also adds a unit test on tooltips for sanitizing the same template twice. Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/tooltip.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index 3c2423921d..0f924c47d4 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -1333,4 +1333,24 @@ $(function () {
assert.strictEqual(tooltip.hasClass('a b'), true)
assert.strictEqual(tooltip.hasClass('tooltip fade bs-tooltip-top show'), true)
})
+
+ QUnit.test('HTML content can be passed through sanitation multiple times', function (assert) {
+ assert.expect(2)
+
+ // Add the same tooltip twice, so the template will be sanitized twice as well.
+ for (var i = 0; i <= 1; i++) {
+ $('<a href="#" rel="tooltip" data-trigger="click" title="<img src=\'test.jpg\'>" />')
+ .appendTo('#qunit-fixture')
+ .bootstrapTooltip({
+ html: true
+ })
+ .bootstrapTooltip('show')
+ }
+
+ var tooltip1Image = $('.tooltip:first img')
+ var tooltip2Image = $('.tooltip:last img')
+
+ assert.strictEqual(tooltip1Image.attr('src'), 'test.jpg')
+ assert.strictEqual(tooltip2Image.attr('src'), 'test.jpg')
+ })
})