Skip to content

console/test: serialize DOM nodes as markup in Bun.inspect and matcher utils - #35712

Open
robobun wants to merge 11 commits into
mainfrom
farm/113ee132/dom-node-formatter
Open

console/test: serialize DOM nodes as markup in Bun.inspect and matcher utils#35712
robobun wants to merge 11 commits into
mainfrom
farm/113ee132/dom-node-formatter

[autofix.ci] apply automated fixes

32b4b0d
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 25, 2026 in 46m 10s

Code review found 4 potential issues

Found 2 candidates, confirmed 4. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 4
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/jsc/ConsoleObject.rs:5626-5630 attributes.length / childNodes.length used as unbounded loop counts
🟡 Nit src/jsc/ConsoleObject.rs:5665-5674 bun_core::fmt::quote does not escape lone backslashes in DOM attribute values

Annotations

Check warning on line 5630 in src/jsc/ConsoleObject.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

attributes.length / childNodes.length used as unbounded loop counts

Nit: `n = len_v.to_int32().max(0) as u32` is used unclamped as the `for i in 0..n` bound for both `attributes` and `childNodes` (here and in the `pretty_format.rs` twin) — a duck-typed lookalike with `attributes = { length: 0x7fffffff }` drives ~2^31 `get_index` calls, and the `childNodes` loop writes `\n`+indent *before* the `is_cell` guard so a lying `childNodes.length` also blows up the output buffer. `Vec::with_capacity(n.min(64))` already clamps allocation; consider clamping the iteration b

Check warning on line 5674 in src/jsc/ConsoleObject.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

bun_core::fmt::quote does not escape lone backslashes in DOM attribute values

🟡 Nit: `bun_core::fmt::quote(val)` only escapes `"` — its fast-path predicate `contains_newline_or_non_ascii_or_quote` does not test for `\` (0x5C), so `el.setAttribute("data-path", "C:\\Users")` still emits `data-path="C:\Users"` where pretty-format emits `data-path="C:\\Users"`. The resolved comment on this line asked for both `\` and `"`; commit 408bc378 covered only `"`. Same gap in the `pretty_format.rs` twin. Routing the attribute `JSValue` through the quoted-string printer with `quote_str