fix: render Validate binary path modal as HTML instead of raw markup - #10394
Conversation
The endpoint returned a pre-built <b>/<br/> HTML string, and the frontend switched to the escaping alertText() during the XSS hardening pass (9e370d3), so the modal showed literal tags instead of formatted text. Return structured {utility, version} data from the backend and compose the modal content as React elements on the frontend, keeping the untrusted binary version output routed through SafeMessage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review. WalkthroughThe binary path validation endpoint now returns structured utility/version data. The UI converts this data into JSX alert rows, including a fallback for missing versions. Alert content accepts React nodes, and tests verify bold labels and line breaks render as elements. ChangesBinary path validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Binary-path validation now renders utility names and version output safely as formatted dialog content, including a not-found message for empty results. The change is ready to merge. Sequence Diagram(s)sequenceDiagram
participant ValidationUI
participant validate_binary_path
participant BrowserNotifier
ValidationUI->>validate_binary_path: Submit binary path
validate_binary_path-->>ValidationUI: Return utility/version data
ValidationUI->>BrowserNotifier: Display JSX alert rows
BrowserNotifier-->>ValidationUI: Render alert content
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Backend (misc/init.py) — Clean change. Returning structured [{utility, version}] instead of an HTML string is the right API design. Removing gettext() around the whole blob was also a latent bug fix. |
|| instead of ?? — an empty-string version from an unexpected '--version' output shape should still show the fallback message. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
hiteshjambhale
left a comment
There was a problem hiding this comment.
Tested manually — validated with /opt/homebrew/bin, versions render correctly with bold labels and line breaks. No raw /
tags.
LGTM ✅
Summary
Fixes #10393.
Preferences → Paths → Binary Paths → Validate binary pathwas showing literal<b>...</b>/<br/>tags instead of formatted text. The endpoint built a pre-rendered HTML string, and the frontend call site was switched to the escapingnotifier.alertText()during the XSS hardening pass (9e370d3cb) — correct for untrusted binary output, but the backend never stopped speaking HTML.misc.validate_binary_pathnow returns structured data ([{utility, version}]) instead of markup.<b>label +SafeMessagefor the untrusted version text) and callsnotifier.alert(), so nothing is HTML-parsed and no plaintext escaping is needed.binary_path.ui.js→.jsxsince it now contains JSX; widenedAlertContent'stextpropType tonodeto match its existing behavior (it already accepted non-string nodes from other callers).Test plan
pycodestyleon the changed Python file — cleanyarn run eslinton the changed JS/JSX files — cleanyarn run jest --testPathPatterns="binary_path.ui"— 3 passed, including a new case asserting bold labels/line breaks render and no literal<b>/<br/>ever appears in the DOMyarn run jest --testPathPatterns="ModalProvider"— 4 passed (propType widening doesn't regress existing behavior)Summary by CodeRabbit
Bug Fixes
UI Improvements