1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-12 08:34:08 +02:00

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>
This commit is contained in:
Nikon the Third
2021-02-19 09:24:53 +01:00
committed by GitHub
parent 454d8ae1f4
commit e8f08d1802
2 changed files with 11 additions and 1 deletions

View File

@@ -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')
})
})
})