Merge pull request #1801 from umap-project/1796-add-purify-attributes

fix: allow `dir` and `title` attributes
This commit is contained in:
David Larlet 2024-05-07 09:40:27 -04:00 committed by GitHub
commit dcad0e1bb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -88,7 +88,7 @@ export function escapeHTML(s) {
'span',
],
ADD_ATTR: ['target', 'allow', 'allowfullscreen', 'frameborder', 'scrolling'],
ALLOWED_ATTR: ['href', 'src', 'width', 'height', 'style'],
ALLOWED_ATTR: ['href', 'src', 'width', 'height', 'style', 'dir', 'title'],
// Added: `geo:` URL scheme as defined in RFC5870:
// https://www.rfc-editor.org/rfc/rfc5870.html
// The base RegExp comes from:

View file

@ -185,6 +185,13 @@ describe('Utils', function () {
assert.equal(Utils.escapeHTML('<a href="geo:1,2"></a>'), '<a href="geo:1,2"></a>')
})
it('should not escape dir and title attributes', function () {
assert.equal(
Utils.escapeHTML('<a title="Title" dir="rtl"></a>'),
'<a dir="rtl" title="Title"></a>'
)
})
it('should not fail with int value', function () {
assert.equal(Utils.escapeHTML(25), '25')
})