Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,18 @@ export class AttributesTests extends RenderTest {
this.assertHTML('<svg viewBox="0 0 100 100" />');
this.assertStableNodes();
}

@test
'sanitizes url attributes regardless of attribute name case'() {
this.render('<a HREF={{this.foo}}></a>', { foo: 'javascript:foo()' });
this.assertHTML('<a href="unsafe:javascript:foo()"></a>');

this.rerender({ foo: 'http://foo.bar' });
this.assertHTML('<a href="http://foo.bar"></a>');

this.rerender({ foo: 'javascript:foo()' });
this.assertHTML('<a href="unsafe:javascript:foo()"></a>');
}
}

jitSuite(AttributesTests);
Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/runtime/lib/dom/sanitized-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ function has(array: Array<string>, item: string): boolean {
}

function checkURI(tagName: Nullable<string>, attribute: string): boolean {
return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute);
return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute.toLowerCase());
}

function checkDataURI(tagName: Nullable<string>, attribute: string): boolean {
if (tagName === null) return false;
return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute);
return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute.toLowerCase());
}

export function requiresSanitization(tagName: string, attribute: string): boolean {
Expand Down
Loading