Skip to content

[Bug]: EPUB literal XML declarations disappear or reject preview #36623

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Open an EPUB whose XHTML chapter includes <pre><![CDATA[<!DOCTYPE html>]]></pre>.
  2. Inspect the code listing in the file preview. The literal DOCTYPE disappears.
  3. Replace the listing with <pre><![CDATA[<!ENTITY author "Ada">]]></pre> and reopen the book.
  4. The entire preview now fails. An XML comment containing a literal ENTITY example also causes the failure.

A deterministic repository repro extends the existing “reads EPUB chapters” fixture in apps/web/src/components/files/FilePreviewPanel.test.ts with those chapter fragments, then runs pnpm exec vp test run apps/web/src/components/files/FilePreviewPanel.test.ts -t 'reads EPUB chapters'.

Expected behavior

Literal XML examples in CDATA display as text, and comments do not invalidate the preview. Actual internal-subset declarations remain unsupported.

Actual behavior

The DOCTYPE listing is empty; an ENTITY listing or comment makes the panel show “No preview for this file” with “This document contains invalid or unsupported XML.” The declaration prefilter scans literal CDATA and comments as if they were declarations.

Impact

Minor bug or occasional failure

Version or commit

main @ e4688f7

Environment

Web preview on Linux. Desktop shares the same preview parser and worker; the desktop shell was not separately exercised. Mobile does not use this preview.

Logs or stack traces

Error: This document contains invalid or unsupported XML.

Screenshots, recordings, or supporting files

Real-app scenario reproduces preview rejection on main and renders the listing with the fix.

Workaround

Encode the examples as escaped XHTML text instead of CDATA.

Activity

  1. added
    vouch:trusted
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions