Skip to content

fix(server): EPUB text skips hidden map groups that also set a transform - #48478

Open
StiensWout wants to merge 3 commits into
pingdotgg:mainfrom
StiensWout:wf/find-ab4153432ffe5ae7919f5b06
Open

StiensWout wants to merge 3 commits into
pingdotgg:mainfrom
StiensWout:wf/find-ab4153432ffe5ae7919f5b06

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Text extracted from EPUB attachments included SVG labels hidden with an important display: none when the same inline style also had a value with brackets, such as transform: translate(10px), so agents could quote labels the reader hides. The style check now reads unquoted url(...) values as single tokens and splits declarations only at top-level semicolons, so bracketed values no longer hide or reveal labels incorrectly.

Reproduction on main

Commit 4ec5222ffd (main). The extracted text includes the hidden Closed ferry berth label. Expected: The extracted text includes the visible map labels and omits the hidden berth label.

  1. Attach the sample EPUB with a standalone map whose closed berth label is hidden in the reader to a Replay (dev) thread.
  2. Send the attachment.
  3. Open the extracted text saved beside the attachment on the local server.

The cause is at apps/server/src/provider/documentTextWorker.ts:308. Ran cd apps/server && pnpm exec vp test run src/provider/userInputAttachments.test.ts with the repro test added: it failed in 2 of 2 runs on a clean checkout, with not to contain 'Closed ferry berth' in the output.

Evidence

Environment: Linux x64, the repository's own tests.

Proven: the repro fails at the test commit 70e72927ef and passes on the head 2c6fc4acd0, both on main efbd62a7a7.

Before After
Commit 70e72927ef 2c6fc4acd0
Result failed with "not to contain 'Closed ferry berth'" passed

Tests

  • 70e72927ef adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed efbd62a7a700a29ad545f8334b2139407875dab3 passed on head.

Not in this change

  • EPUB image alt text uses a separate inline-style regex for display/visibility; it is a different check and is unchanged.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol

StiensWout and others added 3 commits December 3, 2026 23:08
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Inline styles with parentheses, such as a transform, were treated as
unreadable, so an important display:none beside them was ignored.
Split declarations at top-level semicolons instead.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…alue

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Dec 3, 2026
let badString = false;
const declarations = style.replaceAll(
/\/\*[\s\S]*?(?:\*\/|$)|"[^"]*(?:"|$)|'[^']*(?:'|$)/g,
/(?<![\w-])url\((?![\t\n\f\r ]*["'])[^)]*(?:\)|$)|\/\*[\s\S]*?(?:\*\/|$)|"[^"]*(?:"|$)|'[^']*(?:'|$)/gi,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High provider/documentTextWorker.ts:299

hasImportantDisplayNone returns true for style="--a: #url(/*); display: none !important; --b: url(*/)", so the EPUB caller removes a visible element and its text even though display: none is inside a CSS comment. The URL matcher treats url( after # or a non-ASCII identifier character as a URL token and strips the comment delimiters; recognize CSS name-code-point and hash-token boundaries instead.

Suggested change
/(?<![\w-])url\((?![\t\n\f\r ]*["'])[^)]*(?:\)|$)|\/\*[\s\S]*?(?:\*\/|$)|"[^"]*(?:"|$)|'[^']*(?:'|$)/gi,
/(?<![#\w\u0080-\u{10FFFF}-])url\((?![\t\n\f\r ]*["'])[^)]*(?:\)|$)|\/\*[\s\S]*?(?:\*\/|$)|"[^"]*(?:"|$)|'[^']*(?:'|$)/giu,
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/provider/documentTextWorker.ts around line 299:

`hasImportantDisplayNone` returns `true` for `style="--a: #url(/*); display: none !important; --b: url(*/)"`, so the EPUB caller removes a visible element and its text even though `display: none` is inside a CSS comment. The URL matcher treats `url(` after `#` or a non-ASCII identifier character as a URL token and strips the comment delimiters; recognize CSS name-code-point and hash-token boundaries instead.

@macroscopeapp

macroscopeapp Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Would Approve

Macroscope's review found this PR approvable — The change improves EPUB hidden-text filtering for styles containing transforms and other bracketed values. The reported CSS-tokenization issue can omit visible extracted text and remains subject to the separate correctness blocking gate.

Needs human approval because:

  • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity

Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The style parser now handles balanced nested delimiters when checking for display: none !important declarations. SVG extraction tests cover styles with functions, braces, comments, URLs, and later display overrides.

Changes: SVG hidden-text detection

Layer / File(s) Summary
Parse display-none styles and verify SVG extraction
apps/server/src/provider/documentTextWorker.ts, apps/server/src/provider/userInputAttachments.test.ts
The parser masks unquoted URLs, rejects malformed URL syntax and mismatched or unclosed delimiters, and splits declarations at top-level semicolons. SVG tests cover nested styles and assert which text is included or excluded.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: jadelike-wine, kiritoxdone, lucenx9

Merge Risk: Minimal · up to 2c6fc

This fixes hidden SVG labels leaking into extracted EPUB text when inline styles contain bracketed values. The change is narrow and tested, and I found no remaining merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the server-side EPUB text extraction fix and the hidden map groups with a transform. It matches the main change: the style check now handles bracketed values such as transform: transla…
Description check Passed The description follows the template's sections in substance. It gives the problem (hidden SVG labels leaked into extracted EPUB text when a bracketed transform value was present) and the change (unqu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the server-side EPUB text extraction fix and the hidden map groups with a transform. It matches the main change: the style check now handles bracketed values such as transform: translate(10px) when it detects display: none !important. The title uses the conventional commit form and is specific, so it passes.

Full details: Description check

Explanation

The description follows the template's sections in substance. It gives the problem (hidden SVG labels leaked into extracted EPUB text when a bracketed transform value was present) and the change (unquoted url(...) tokens are read as single tokens and declarations split only at top-level semicolons). It gives reproduction steps, a base commit, a before/after table for the failing and passing commits, and test commands. Scope is only partly covered: it describes the bug but does not state why no issue is linked, and it does not link an issue or maintainer request. The Verification section gives observed results, not just 'tests pass'. The Environment and author attribution are present. Missing items are minor, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between efbd62a and 2c6fc4a.

Files selected for processing: 2

  • apps/server/src/provider/documentTextWorker.ts
  • apps/server/src/provider/userInputAttachments.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant