Skip to content

Commit

Permalink
fix(icon): sanitizer checks attribute name instead of value (#1087)
Browse files Browse the repository at this point in the history
resolves #1088
  • Loading branch information
dauriamarco authored Aug 26, 2022
1 parent 7dd6909 commit 8d898d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/icon/test/validate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('isValid', () => {
const el = {
nodeType: 1,
nodeName: 'svg',
attributes: [{ value: 'onload' }],
attributes: [{ name: 'onload' }],
childNodes: []
} as any;
expect(isValid(el)).toBe(false);
Expand All @@ -17,7 +17,7 @@ describe('isValid', () => {
const el = {
nodeType: 1,
nodeName: 'svg',
attributes: [{ value: 'OnClIcK' }],
attributes: [{ name: 'OnClIcK' }],
childNodes: []
} as any;
expect(isValid(el)).toBe(false);
Expand Down
4 changes: 2 additions & 2 deletions src/components/icon/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export const isValid = (elm: HTMLElement) => {
}

for (let i = 0; i < elm.attributes.length; i++) {
const val = elm.attributes[i].value;
if (isStr(val) && val.toLowerCase().indexOf('on') === 0) {
const name = elm.attributes[i].name;
if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {
return false;
}
}
Expand Down

0 comments on commit 8d898d7

Please sign in to comment.