Skip to content

Commit db0e30a

Browse files
docs(solid-no-innerhtml): correct port comment about static-string handling
Bugbot (PR #513) flagged that the rule's header claimed "Static string values are still flagged because Solid reports them as dangerous when the rule is left at its default," but the actual code permits a static string `innerHTML="..."` on a childless element. The code behaviour is correct — it mirrors upstream's `allowStatic: true` default — only the comment was wrong. Rewrites the comment to enumerate the three real diagnostic cases (`dangerouslySetInnerHTML`, dynamic `innerHTML`, static `innerHTML` with JSX children) and to note explicitly that childless-static is intentionally allowed. Also documents the upstream `is-html` suggestion path as the one omission, so a future reader doesn't re-flag it. Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
1 parent 265ec80 commit db0e30a

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

packages/oxlint-plugin-react-doctor/src/plugin/rules/solid/solid-no-innerhtml.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,22 @@ const extractStaticStringValue = (node: EsTreeNode | null): string | null => {
2323
return null;
2424
};
2525

26-
// Port of `solid/no-innerhtml` — flags `innerHTML={...}` (a Solid
27-
// special prop) because passing unsanitized input is an XSS risk,
28-
// plus the React-style `dangerouslySetInnerHTML` which Solid does
29-
// not support. Static string values are still flagged because Solid
30-
// reports them as dangerous when the rule is left at its default
31-
// (we don't depend on `is-html` to keep the port footprint tight).
26+
// Port of `solid/no-innerhtml`. Three distinct diagnostics:
27+
//
28+
// 1. `dangerouslySetInnerHTML={...}` — always flagged. Solid does
29+
// not honour the React-style prop, so any use is a silent bug.
30+
// 2. `innerHTML={dynamic}` — flagged as dangerous XSS source.
31+
// 3. `innerHTML="..."` on an element with JSX children — flagged
32+
// because the static markup overwrites the children.
33+
//
34+
// Static `innerHTML="..."` on a childless element is intentionally
35+
// NOT flagged — this matches upstream's `allowStatic: true` default,
36+
// which exists so authors can ship known-safe inline snippets without
37+
// noise. Upstream additionally calls `is-html(value)` to suggest
38+
// `innerText` when the literal isn't actually markup; we skip that
39+
// to avoid pulling in the dataset, which only costs us the
40+
// `notHtml` suggestion path — the security-relevant cases above are
41+
// fully covered.
3242
export const solidNoInnerHtml = defineRule<Rule>({
3343
id: "solid-no-innerhtml",
3444
severity: "error",

0 commit comments

Comments
 (0)