Repository navigation
fix(grounding): harden native sanitizer and address review nits - #473
Conversation
Strip base tags and unsafe img src on native, clarify attribute allowlist logic, and stop re-attaching the web wheel listener on layout sync. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Pull request overview
This PR tightens defense-in-depth sanitization for grounding HTML rendering, aligning the native regex-based path more closely with the web allowlist sanitizer, and removes an unnecessary wheel-listener re-subscription on web.
Changes:
- Extend native executable-markup stripping to remove
<base>alongside<link>/<meta>. - Add native
<img src>URL sanitization using the sameisSafeHttpUrlgate as anchorhref, factoring shared helper logic. - Refine the web allowlist attribute check readability and make the web scrollport wheel listener attach only once; add/extend native sanitizer unit tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/utils/sanitizeGroundingHtml.ts | Expands native regex sanitizer to strip <base> and sanitize <img src>, extracting shared URL-attribute stripping helper. |
| src/utils/groundingShadowContent.ts | Clarifies attribute allowlist branching (on* reject, aria-*/data-* allow). |
| src/utils/tests/sanitizeGroundingHtml.test.ts | Adds tests for additional removed tags and img src URL validation. |
| src/components/GroundingHtml.web.tsx | Removes unnecessary effect re-run by changing the wheel listener effect deps to []. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Anchor href/src patterns now require start-of-attrs or whitespace (avoiding data-href/data-src false positives), support xlink:href, and use last-wins semantics when duplicate URL attributes are present. Co-authored-by: Cursor <cursoragent@cursor.com>
/fix-pr follow-upCommit: Review resolution
Verification
|
Description
Defense-in-depth cleanup for grounding HTML rendering, addressing follow-up items from the PR #472 Copilot review. Hardens the native WebView sanitizer to match the web allowlist behavior, clarifies attribute allowlist logic, and removes an unnecessary wheel listener re-subscription on web.
Type of Change
Related Issue
Follow-up to PR #472 Copilot review feedback.
Changes Made
<base>tags in the native regex sanitizer alongside<link>and<meta>img srcon the native path using the sameisSafeHttpUrlgate as anchorhrefstripUnsafeUrlAttributehelper for anchor and img URL attributesisAllowedGroundingAttributeinto expliciton*/aria-*/data-*branches[contentWidth]to[]Testing
Platforms Tested
Test Steps
npm run typechecknpm run lintnpm run test -- --testPathPattern='sanitizeGroundingHtml|groundingShadowContent'Screenshots
N/A — sanitizer and event-listener changes only; no visible UI change expected.
Before
N/A
After
N/A
Checklist
Additional Notes
None of these changes address active critical vulnerabilities; they align native sanitization with the existing web allowlist and close out low-priority maintainability items from the prior review.
Made with Cursor