Skip to content

Commit

Permalink
feat: Allow loading attribute on img (#278)
Browse files Browse the repository at this point in the history
Signed-off-by: maosmurf <[email protected]>
  • Loading branch information
maosmurf authored Mar 23, 2023
1 parent 4c3c758 commit 8884b21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getDefaultWhiteList() {
header: [],
hr: [],
i: [],
img: ["src", "alt", "title", "width", "height"],
img: ["src", "alt", "title", "width", "height", "loading"],
ins: ["datetime"],
li: [],
mark: [],
Expand Down
6 changes: 6 additions & 0 deletions test/test_xss.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ describe("test XSS", function() {
),
'<img width="100" height="200" title="xxx" alt="\'yyy\'">'
);
assert.equal(
xss(
'<img loading="lazy">'
),
'<img loading="lazy">'
);

// 使用Tab或换行符分隔的属性
assert.equal(
Expand Down

0 comments on commit 8884b21

Please sign in to comment.