You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(web): EPUB SVG images that use epub:type no longer render broken - #44192
When an EPUB 3 file shows a standalone .svg image (<img>, <object>, CSS url(), <input type="image">, or SVG <image>) using epub:type, the web preview renders a broken image instead of the graphic. Serializing it to an image/svg+xml blob keeps epub:type without xmlns:epub, so Chromium's XML parser rejects it as unbound.
Change
render() in apps/web/src/components/files/epubPreview.ts now adds xmlns:epub="http://www.idpf.org/2007/ops" on <svg> only while serializing an SVG image resource (svgDepth > 0). Inline <svg> and SVG spine pages use the HTML path and stay unchanged. epub:type is the only prefixed attribute reaching that markup (xml:space uses the reserved prefix; xlink:href rewrites to href).
Scope
Bug fix for wrong rendered output (a broken EPUB image), introduced in #43960. No issue is filed for this small fix (4 additions, 1 deletion in epubPreview.ts) of an obvious bug.
Verification
Put an EPUB 3 with a standalone epub:type SVG image in a project.
Open it in the web app's Files panel.
The image renders broken on base and renders cleanly with this fix.
Setup: Linux, Chromium in the T3 Browser panel, 1280x800, light theme, fresh isolated data on each commit.
Figure 1 (epub:type) shows only alt text "Figure 1: orbit diagram" (naturalWidth 0); Figure 2 renders.
Figure 1 (epub:type) and Figure 2 both render (naturalWidth 320).
AttachmentFilePreview.browser.test.tsx ("renders EPUB publisher styles and follows an anchored link to a fixed-layout section", adding epub:type to OPS/illustration.svg) fails on d898612a03 and passes on 73032a7a80; vp run check:changed passed. On a local merge with 52c5a9ae6d, the test, FilePreviewPanel.test.ts (65/65) and apps/web typecheck pass.
Reviewing files that changed from the base of the PR and between 73032a7 and 742f4aa.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The EPUB preview renderer now adds the EPUB operations namespace to nested SVG roots. The browser test fixture now declares EPUB metadata on its SVG root and poster rectangle.
Changes: EPUB SVG preview
Layer / File(s)
Summary
Nested SVG namespace and fixture apps/web/src/components/files/epubPreview.ts, apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
The renderer adds the EPUB operations namespace when svgDepth is nonzero. The test fixture adds EPUB namespace and type attributes to the SVG root and poster rectangle.
This fixes broken standalone SVG images in EPUB previews when they use epub:type. The change is small and localized, the test covers the reported failure, and no merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix and its scope: EPUB SVG images that use epub:type no longer render broken. The change adds xmlns:epub to svg roots during serialization of SVG image resources in epubPreview.ts…
Description check
The description follows the template closely. It has Problem, Change, Scope, and Verification sections. It explains the bug, the code change, and why no issue is linked for this small fix. It gives be…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the fix and its scope: EPUB SVG images that use epub:type no longer render broken. The change adds xmlns:epub to svg roots during serialization of SVG image resources in epubPreview.ts, so the title matches the main change. It follows the conventional commit form with a plain-language description.
Full details: Description check
Explanation
The description follows the template closely. It has Problem, Change, Scope, and Verification sections. It explains the bug, the code change, and why no issue is linked for this small fix. It gives before/after evidence with images, test names, and results, and it lists what was not tested. It also states the authoring model in the closing line, as the template asks. The Scope section cites the commit introducing the bug, and the author states why no issue is filed. Minor gap: the template asks for a short recording only when motion or interaction matters, so none is needed here.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Opened the same synthetic EPUB on both commits in the real web app (Chromium, 1440×1080, light theme, fresh databases). Image A uses epub:type on its SVG root and child rect; image B is the plain SVG control.
…ingdotgg#44192)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When an EPUB 3 file shows a standalone
.svgimage (<img>,<object>, CSSurl(),<input type="image">, or SVG<image>) usingepub:type, the web preview renders a broken image instead of the graphic. Serializing it to animage/svg+xmlblob keepsepub:typewithoutxmlns:epub, so Chromium's XML parser rejects it as unbound.Change
render()inapps/web/src/components/files/epubPreview.tsnow addsxmlns:epub="http://www.idpf.org/2007/ops"on<svg>only while serializing an SVG image resource (svgDepth > 0). Inline<svg>and SVG spine pages use the HTML path and stay unchanged.epub:typeis the only prefixed attribute reaching that markup (xml:spaceuses the reserved prefix;xlink:hrefrewrites tohref).Scope
Bug fix for wrong rendered output (a broken EPUB image), introduced in #43960. No issue is filed for this small fix (4 additions, 1 deletion in
epubPreview.ts) of an obvious bug.Verification
epub:typeSVG image in a project.Setup: Linux, Chromium in the T3 Browser panel, 1280x800, light theme, fresh isolated data on each commit.
Steps: Files panel →
sample-figures.epub→ hide file explorer → maximize panel.Figure 1 (epub:type) shows only alt text "Figure 1: orbit diagram" (naturalWidth 0); Figure 2 renders.
Figure 1 (epub:type) and Figure 2 both render (naturalWidth 320).
AttachmentFilePreview.browser.test.tsx("renders EPUB publisher styles and follows an anchored link to a fixed-layout section", addingepub:typetoOPS/illustration.svg) fails ond898612a03and passes on73032a7a80;vp run check:changedpassed. On a local merge with52c5a9ae6d, the test,FilePreviewPanel.test.ts(65/65) andapps/webtypecheck pass.Links
apps/web/src/components/files/AttachmentFilePreview.browser.test.tsxNot shown
Test output
d898612a03(base):73032a7a80(fix):Generated with Gemini 4 Neon in T3 Code Nightly