diff options
author | Nikon the Third <christian.berrer@gmail.com> | 2021-02-19 11:24:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-19 11:24:53 +0300 |
commit | e8f08d1802976b8200551de49354757f84e438cf (patch) | |
tree | 9b93206a442b98c147c1820179f8232bc7e565b6 /js/tests/unit/util | |
parent | 454d8ae1f4513109abeb5b82a015691be5e95f0b (diff) |
Adjust regex `SAFE_URL_PATTERN` for use with test method of regexes. (#33136)
The test method on regexes behaves different than the match method on strings in the presence of the global modifier.
Add a unit test for sanitizing the same template twice.
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/tests/unit/util')
-rw-r--r-- | js/tests/unit/util/sanitizer.spec.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/js/tests/unit/util/sanitizer.spec.js b/js/tests/unit/util/sanitizer.spec.js index 869b8c5615..7379d221f4 100644 --- a/js/tests/unit/util/sanitizer.spec.js +++ b/js/tests/unit/util/sanitizer.spec.js @@ -66,5 +66,15 @@ describe('Sanitizer', () => { expect(result).toEqual(template) expect(DOMParser.prototype.parseFromString).not.toHaveBeenCalled() }) + + it('should allow multiple sanitation passes of the same template', () => { + const template = '<img src="test.jpg">' + + const firstResult = sanitizeHtml(template, DefaultAllowlist, null) + const secondResult = sanitizeHtml(template, DefaultAllowlist, null) + + expect(firstResult).toContain('src') + expect(secondResult).toContain('src') + }) }) }) |