Skip to content

fix(web): keep Word preview text dark and opaque in dark mode - #804

Merged
pikann merged 1 commit into
masterfrom
fix/pdfjs-dist-cve-docx-dark-text
Nov 20, 2026
Merged

pikann merged 1 commit into
masterfrom
fix/pdfjs-dist-cve-docx-dark-text

Conversation

@pikann

@pikann pikann commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Word previews showed faint text in dark mode: the previewer draws docx on a white page but inherited its translucent-white foreground. Force a dark default text color inside .rfp-docx-container; colors set by the document itself still apply.

Test plan

  • Open a .docx preview in dark mode

@pullfrog pullfrog Bot left a comment

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.

Caution

This PR breaks PDF previews. The app now hands the previewer a 6.2.108 worker while the previewer bundles its own pdf.js 6.1.200, and pdf.js aborts every document load on that version mismatch.

Approach: the Word dark-mode CSS fix is sound, but the dependency bump targets the wrong copy of pdf.js — the one that renders previews lives inside the previewer's bundle and stays at 6.1.200, so the bump both fails to clear the advisory and breaks the PDF path.

Reviewed changes

  • Dependency bump — pdfjs-dist 6.1.200 → 6.2.108 in apps/web/package.json and apps/web/bun.lock; the lockfile now resolves a second, nested copy at 6.1.200 for the previewer.
  • Docx text color — new .rfp-root .rfp-docx-container { color: #171717 } override in apps/web/src/index.css; verified it reaches both docx renderers (the .rfp-legacy-doc-paper layout and the paginated inline-white pages) and matches the previewer's own light-theme foreground (rgb(23 23 23 / .9)).

⚠️ The vulnerable pdf.js is bundled inside the previewer, so this bump cannot clear the advisory

@eternalheart/[email protected] ships its own pdf.js 6.1.200 inside lib/chunks/ and that is the copy that parses and renders PDFs; the top-level pdfjs-dist is only imported for its worker file. Bumping the direct dependency therefore leaves the flagged version in the lockfile (the new nested @eternalheart/react-file-preview/pdfjs-dist entry at apps/web/bun.lock:2410), which is what the Dependabot alert tracks. The latest published previewer is still 1.6.13 with [email protected], so there is no upstream upgrade that fixes this today.

Technical details
# The advisory is not cleared by bumping the app's direct dependency

## Affected sites
- `apps/web/bun.lock:2410` — new nested `[email protected]` resolution under `@eternalheart/react-file-preview`; the vulnerable version stays in the lockfile.
- `apps/web/src/components/files/file-preview.tsx:9` — the app's only use of the top-level `pdfjs-dist` is the worker URL.
- `@eternalheart/[email protected]/lib/chunks/index-Bb9eOVP-.mjs` — bundled pdf.js API, sends `apiVersion: "6.1.200"`.
- `docs/product/file-management.md:85` — states "`pdfjs-dist` is pinned to the library's version"; stale after this change.

## Required outcome
- The PR must not claim to resolve the advisory while a vulnerable copy remains resolved in `apps/web/bun.lock`.
- `docs/product/file-management.md:85` must describe the new arrangement if the pin is intentionally broken.

## Suggested approach (optional)
- Keep the top-level `pdfjs-dist` at the version the previewer bundles until an upstream release bundles >= 6.2.108, and track that upgrade; or
- render PDFs with the app's own pdf.js 6.2.108 (own viewer component) and drop the previewer's PDF path; or
- vendor a matching worker file if a worker-only upgrade is genuinely sufficient for the advisory.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Comment thread apps/web/package.json Resolved
@pikann
pikann force-pushed the fix/pdfjs-dist-cve-docx-dark-text branch from ac940c0 to 17b6b91 Compare November 20, 2026 12:24
@pikann pikann changed the title fix(web): bump pdfjs-dist to 6.2.108 and fix faint Word preview text in dark mode fix(web): keep Word preview text dark and opaque in dark mode Nov 20, 2026

@pullfrog pullfrog Bot left a comment

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.

Caution

The new overrides entry does not fix the PDF breakage. It changes the installed pdfjs-dist copy, but the pdf.js that parses PDFs is inlined inside @eternalheart/[email protected] at 6.1.200, so the 6.2.108 worker still rejects its apiVersion: "6.1.200" and every PDF preview still fails.

Approach: the commit tries to align API and worker by collapsing pdfjs-dist to one resolved version, but the API side is not resolved from node_modules — it is baked into the previewer's lib/chunks/ — so the override cannot reach it, and it removes the lockfile evidence of the vulnerable version without removing the vulnerable code.

Reviewed changes

  • Collapsed pdfjs-dist with a Bun override — added "overrides": { "pdfjs-dist": "6.2.108" } to apps/web/package.json and dropped the nested @eternalheart/react-file-preview/pdfjs-dist 6.1.200 resolution from apps/web/bun.lock.

🚨 overrides cannot reach the previewer's inlined pdf.js

Bun overrides only rewrites the resolved node_modules copy. @eternalheart/[email protected] inlines its own pdf.js 6.1.200 in lib/chunks/index-Bb9eOVP-.mjs and has no runtime import of pdfjs-dist, so the app still serves that 6.1.200 API a 6.2.108 worker from file-preview.tsx:9, and the worker throws on every document load. The same override also removes the nested 6.1.200 lockfile entry without removing the vulnerable code, so Dependabot alert 147 can clear while the vulnerability remains.

Technical details
# The override targets the wrong copy of pdf.js

## Affected sites
- `apps/web/package.json:86` — the override only affects the installed `pdfjs-dist` copy, not code inlined in a dependency.
- `apps/web/src/components/files/file-preview.tsx:9,33` — serves the 6.2.108 worker to the previewer via `configurePdfjs({ workerSrc })`.
- `@eternalheart/[email protected]/lib/chunks/index-Bb9eOVP-.mjs` — inlined pdf.js API; sends `apiVersion: "6.1.200"` and sets `GlobalWorkerOptions.workerSrc` on that inlined module.
- `@eternalheart/[email protected]/lib/chunks/pdf.worker-6kySV6rJ.mjs` — bundled 6.1.200 worker, unused once the app sets `workerSrc`.
- `apps/web/bun.lock:263` — the previewer entry still declares `"pdfjs-dist": "6.1.200"`; the nested resolution was removed by the override.

## Required outcome
- The served worker version must match the previewer's inlined `apiVersion` (6.1.200 today), or PDFs must be rendered by a pdf.js instance the app controls end to end.
- The advisory must not be treated as resolved while the previewer ships vulnerable 6.1.200 code.

## Suggested approach (optional)
- Keep the worker at `[email protected]` until a previewer release bundles >= 6.2.108; or
- render PDFs with the app's own `[email protected]` and stop using the previewer's PDF path; or
- patch the previewer's inlined chunk and worker via `bun patch` (fragile, but keeps the previewer UI).

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

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.

✅ No new issues found.

Approach: the PR is now scoped to the Word dark-mode fix only; the pdfjs-dist bump and the overrides block were reverted, so the worker and the previewer's inlined pdf.js stay on 6.1.200 and PDF previews are unaffected.

Reviewed changes

  • Reverted the pdfjs-dist bump and override — apps/web/package.json and apps/web/bun.lock are back to their base state (pdfjs-dist 6.1.200, no overrides), removing both the worker/API version mismatch and the lockfile masking of the advisory.
  • Retained the docx text-color rule — .rfp-root .rfp-docx-container { color: #171717 } is unchanged from the version already verified against both docx renderers, where the white paper would otherwise inherit the previewer's translucent-white dark-mode foreground.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit 0d14182 into master Nov 20, 2026
1 check passed
@pikann
pikann deleted the fix/pdfjs-dist-cve-docx-dark-text branch November 20, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant