readest/apps/readest-app/extensions/windows-thumbnail
Huang Xin 4f9395859c
fix(security): remediate Dependabot dependency alerts (#7248)
* fix(security): upgrade direct ZIP readers to 9.0.5

Upgrade the app, native narration reader and Windows thumbnail provider;
adapt fallible filenames and optional data offsets. Update both app
lockfiles and the thumbnail lock while preserving unrelated pins.

Verified: 201 app Rust tests, 24 native TTS tests, 6 thumbnail tests under
Wine (1 existing ignored), strict app clippy, formatting and locked CEF
Linux dependency graph. Thumbnail strict clippy reproduces 3 existing
lints on the original source; it passes with those CLI lint allowances.
CEF compilation and native Windows device testing were not run.

This is a dependency/API migration covered by existing archive tests;
no new application behavior is intended. The Windows updater retains
ZIP 4 because its patched release requires an incompatible Tauri family.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* fix(security): update vulnerable JavaScript dependencies

Raise patched dependency floors, scope the modern minimatch upgrade to
v10 consumers, and patch deepmerge prototype writes in both merge loops.
Upgrade the SVG renderer and keep its font shaper external so Node can
load its WASM asset when generating PNGs.

Regression tests fail before the fixes: deepmerge inherits attacker
properties; minimatch expands 256 patterns instead of 64 and performs
500500 comparisons instead of zero. The unpatched image upgrade fails
with a dynamic require of fs / missing hb.wasm. All 31 new tests pass
with the fixes, including actual translation and PDF vendor consumers.

Verified: full unit suite 14714 passed/16 skipped; final focused tests
31 passed; lint, formatting, frozen install, web build and Tauri frontend
build passed. Final web build was repeated after the renderer patch.
Nix hashes still need CI regeneration; CEF compilation was not run.
Version-based audits still flag patched deepmerge and legacy minimatch
3/5, which lack this advisory's vulnerable optimizer.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* build(nix): request fresh security dependency hashes

Invalidate the pnpm and Cargo fixed-output hashes so the PR dependency
check computes the updated stores instead of substituting old cached
stores. Replace both values with the CI-reported hashes before merge.

Verified the diff changes only the two affected hash fields; local Nix
is unavailable. CI verification is pending on this commit.

Co-Authored-By: Claude Code <noreply@anthropic.com>

* build(nix): pin regenerated security dependency hashes

Use the pnpm and Cargo hashes calculated by the PR dependency check
(run 41428540045). Both fetchers completed and reported their actual
fixed-output hashes. Replace the temporary empty values.

Verified against the CI log's pnpm-deps and vendor-staging got values;
git diff --check passes. The final hash-check rerun is pending.

Co-Authored-By: Claude Code <noreply@anthropic.com>

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-11-02 11:50:57 +01:00
..
src fix(security): remediate Dependabot dependency alerts (#7248) 2026-11-02 11:50:57 +01:00
Cargo.lock fix(security): remediate Dependabot dependency alerts (#7248) 2026-11-02 11:50:57 +01:00
Cargo.toml fix(security): remediate Dependabot dependency alerts (#7248) 2026-11-02 11:50:57 +01:00
README.md fix(windows): make Explorer thumbnails opt-in (#7220) 2026-11-01 17:55:42 +01:00

Windows Thumbnail Provider for Readest

This crate provides Windows Explorer thumbnail and preview pane support for eBook files when Readest is set as the default application.

Features

  • Automatic Cover Extraction: Extracts cover images from EPUB, MOBI, AZW, AZW3, FB2, CBZ, CBR files
  • PDF Rendering: Renders PDF pages with Windows.Data.Pdf, the PDF engine built into Windows 10+
  • Preview Pane: IPreviewHandler shows PDF pages (mouse wheel, scrollbar, arrow / Page Up / Page Down / Home / End turn pages) and the cover of other formats
  • Readest Branding: Adds a small Readest icon overlay at the bottom-right corner
  • Smart Caching: Caches generated thumbnails for faster subsequent loads
  • File Association Aware: Only shows thumbnails when Readest is the default app for the file type
  • COM Integration: Full Windows Shell extension implementation via IThumbnailProvider

Supported Formats

Format Extension Cover Source
EPUB .epub OPF manifest cover reference
MOBI/AZW .mobi, .azw, .prc EXTH cover offset
AZW3/KF8 .azw3, .kf8 KF8 format cover
FB2 .fb2 <binary> coverpage element
Comic Book .cbz, .cbr First image in archive
PDF .pdf First page
Plain Text .txt Generated placeholder

Building

Library Only

cargo build --release

COM DLL (for Windows Explorer integration)

cargo build --release --features com

CLI Tool

cargo build --release --features cli

Installation

The NSIS installer registers the DLL for Explorer previews. File Explorer thumbnails are off by default. Enable Settings → Behavior → File Explorer → Use Readest for File Explorer thumbnails to opt in on this Windows account. The preference stays on this device and survives updates. Turning it off removes only Readest's thumbnail registrations; preview-pane handlers and other providers remain unchanged.

Upgrading from a version that registered thumbnails automatically removes those legacy registrations unless you have opted in. The setting requires the installed DLL; portable copies cannot enable it on their own.

Manual Registration (for development)

# Register the DLL
regsvr32 /s target\release\windows_thumbnail.dll

# Unregister the DLL
regsvr32 /s /u target\release\windows_thumbnail.dll

# Refresh Explorer to see changes
ie4uinit.exe -show

After registration, you may need to restart Windows Explorer or log out/in for changes to take effect.

Usage (Development / Manual testing)

For local development and testing, build the Windows DLL (or the library) from the Readest Tauri app folder and register it manually. The legacy CLI test harness used to live in the separate packages/tauri workspace, but the thumbnail handler implementation now lives inside Readest's Tauri app.

Build the DLL (for Windows explorer integration):

cd apps/readest-app/src-tauri
cargo build --release --manifest-path Cargo.toml --features com

The standalone CLI test harness is no longer distributed with the app. To test the thumbnail provider locally, build and register the DLL as shown above and use a small test harness that imports readestlib's thumbnail code or use Explorer after registering the handler.

Manual registration for development (register the generated DLL):

# Register the DLL
regsvr32 /s target\release\windows_thumbnail.dll

# Unregister the DLL
regsvr32 /s /u target\release\windows_thumbnail.dll

# Refresh Explorer to see changes
ie4uinit.exe -show

This generates a thumbnail with the Readest overlay at the specified size.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    Windows Explorer                              │
├─────────────────────────────────────────────────────────────────┤
│                          │                                       │
│    IThumbnailProvider ───┼──► ThumbnailProvider                  │
│                          │         │                             │
│                          │         ▼                             │
│                          │    Check File Association             │
│                          │    (is Readest the default?)          │
│                          │         │                             │
│                          │         ▼ (if yes)                    │
│                          │    Extract Cover Image                │
│                          │         │                             │
│                          │         ▼                             │
│                          │    Add Readest Overlay                │
│                          │         │                             │
│                          │         ▼                             │
│                          │    Return HBITMAP                     │
│                          │                                       │
└─────────────────────────────────────────────────────────────────┘

COM Details

  • CLSID: {A1B2C3D4-E5F6-7890-ABCD-EF1234567890} (one class serves both handlers)
  • Shell Thumbnail Handler GUID: {e357fccd-a995-4576-b01f-234630154e96}
  • Shell Preview Handler GUID: {8895b1c6-b41f-4c1c-a562-0d564250836f}, hosted by prevhost.exe (AppID {6d2b5079-2f0b-48dd-ab7f-97cec514d30b})
  • Threading Model: Apartment

How It Works

  1. When Windows Explorer needs a thumbnail, it queries the registered shell extension
  2. The COM DLL implements IInitializeWithItem to receive the file path
  3. It checks if Readest.exe is the default application for that file type using AssocQueryStringW
  4. If Readest is the default, it extracts the cover and generates the thumbnail
  5. If Readest is NOT the default, it returns S_FALSE to let Windows use other handlers

This ensures thumbnails only appear for files the user has associated with Readest.

Thumbnail opt-in and preview registration claim an extension's slot only when it is empty or already Readest's. Opt-out and uninstall remove only Readest's own entries, so handlers from other apps (e.g. SageThumbs, Edge's PDF previewer, Adobe, SumatraPDF) are left alone.

Installer regression test

From src-tauri/nsis/tests, compile makensis explorer-thumbnails.nsi and run explorer-thumbnails-test.exe in a disposable Windows user account or isolated Wine prefix. The harness writes fixture registry entries and reports its result in explorer-thumbnails-test.log; never run it against your normal Windows registry. It covers the default, legacy registration migration, per-user and machine install scopes, opt-in persistence, opt-out, uninstall, and third-party handlers.

License

MIT License - See LICENSE file for details.