Skip to content

Commit

Permalink
Fix matching of Clutz-renamed types against allowed type names. (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicknellr authored Dec 2, 2022
1 parent 5eaf910 commit 92c084d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function matchesAtLeastOneNominalType(typeNames: string[], typeB: SimpleType): b
return true;
}
const normalized = normalizeTypeName(typeBName);
if (normalized !== undefined && typeNames.includes(typeBName)) {
if (normalized !== undefined && typeNames.includes(normalized)) {
return true;
}
}
Expand Down
26 changes: 26 additions & 0 deletions packages/lit-analyzer/src/test/rules/security-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,29 @@ tsTest(testName, t => {
const { diagnostics } = getDiagnostics(preface + "html`<div .style=${anyValue}></div>`", { securitySystem: "ClosureSafeTypes" });
hasNoDiagnostics(t, diagnostics);
});

testName = "Types renamed by Clutz are properly matched against allowed types.";
tsTest(testName, t => {
const { diagnostics } = getDiagnostics(
[
{
fileName: "main.ts",
text: `
// A type name known to have been output by Clutz.
class module$contents$goog$html$SafeUrl_SafeUrl {}
html\`<a href='\${"abc" as module$contents$goog$html$SafeUrl_SafeUrl}'>This is a link.</a>\`;
// A type name of the same format.
class module$some$clutz$name_TrustedResourceUrl {}
html\`<script src='\${"abc" as module$some$clutz$name_TrustedResourceUrl}'></script>\`;
`
}
],
{
securitySystem: "ClosureSafeTypes"
}
);
hasNoDiagnostics(t, diagnostics);
});

0 comments on commit 92c084d

Please sign in to comment.