Skip to content
Source
Sign inSign up
pingdotgg/t3code

EPUB attachments include hidden labels from standalone SVG chapters #48024 (GitHub #48023)

ClosedKiritoXDone(GitHub profile, opens in a new tab) opened this issue 0 comments

Attaching a fixed-layout map as an SVG spine document gives the agent two conflicting boarding gates. The map contains a visible “Board at Gate 12.” label and a superseded “Board at Gate 4.” label inside a group with style="display:none !important". Chromium renders only Gate 12. The same map embedded in an XHTML chapter already extracts correctly.

Reproduce

I ran this on macOS 26.2, Node 26.13.1, on upstream commit 358cc548f7. Save the Python program below as repro.py in an empty directory and run python3 repro.py. It creates one EPUB with two chapters containing the same SVG markup, plus the standalone SVG and XHTML for inspection in a browser.

From a checkout with dependencies installed, run:

node apps/server/src/bin.ts __document-text /path/to/gates.epub .epub
Fixture generator (Python standard library)
from pathlib import Path
from zipfile import ZipFile, ZipInfo

out = Path(__file__).resolve().parent
svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="360" height="100">
  <text x="10" y="28">Board at Gate 12.</text>
  <g style="display:none !important"><text x="10" y="54">Board at Gate 4.</text></g>
  <text x="10" y="80" style="display:none!important;display:inline!important">Departure 09:30.</text>
</svg>'''
html = '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Gate map</title></head><body>' + svg + '</body></html>'
(out / 'map.svg').write_text(svg)
(out / 'inline.xhtml').write_text(html)
with ZipFile(out / 'gates.epub', 'w') as book:
    for name, data in {
        'mimetype': 'application/epub+zip',
        'META-INF/container.xml': '<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0"><rootfiles><rootfile full-path="book.opf" media-type="application/oebps-package+xml"/></rootfiles></container>',
        'book.opf': '''<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="id">
          <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:identifier id="id">urn:example:gates</dc:identifier><dc:title>Gate Map</dc:title><dc:language>en</dc:language><meta property="dcterms:modified">2026-01-01T00:00:00Z</meta></metadata>
          <manifest><item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/><item id="inline" href="inline.xhtml" media-type="application/xhtml+xml" properties="svg"/><item id="map" href="map.svg" media-type="image/svg+xml"/></manifest>
          <spine><itemref idref="inline"/><itemref idref="map"/></spine></package>''',
        'nav.xhtml': '<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"><head><title>Contents</title></head><body><nav epub:type="toc"><ol><li><a href="inline.xhtml">Inline map</a></li><li><a href="map.svg">Standalone map</a></li></ol></nav></body></html>',
        'inline.xhtml': html,
        'map.svg': svg,
    }.items():
        book.writestr(ZipInfo(name), data)

Expected and observed

Both chapters should give the agent Gate 12 and the 09:30 departure. The second chapter also contains Gate 4 on this commit. The departure label has two competing inline declarations and serves as a visible control.

Captured stdout from the attachment command
## Chapter 1

  Board at Gate 12.
  
  Departure 09:30.

## Chapter 2

  Board at Gate 12.
  Board at Gate 4.
  Departure 09:30.

EPUBCheck 5.4.0 reports 0 errors and 0 warnings. In Chromium 156.0.8078.4 the rendered SVG text elements (those with a nonempty getClientRects()) were identical for the two files:

Chromium 156.0.8078.4
inline.xhtml: ["Board at Gate 12.","Departure 09:30."]
map.svg: ["Board at Gate 12.","Departure 09:30."]

Fixture SHA-256: 046014ae96b31f35f0359a06094a1a5e03bfdb1b010954896aebcc74f4cf7bb2.

  1. tanstack-source added labelsbug

  2. juliusmarminge closed this

Sign in to join this conversation.