Skip to content

Commit b81a77d

Browse files
committed
fix: do not check fragment identifiers on PDF references
Fix #1482
1 parent da4f541 commit b81a77d

File tree

8 files changed

+60
-1
lines changed

8 files changed

+60
-1
lines changed

src/main/java/org/w3c/epubcheck/core/references/ResourceReferencesChecker.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,15 @@ else if (MIMEType.SVG.is(targetMimetype) && !fragment.isValid())
169169
{
170170
Reference.Type targetIDType = resourceRegistry.getIDType(fragment.getId(),
171171
targetResource);
172-
if (targetIDType == null)
172+
173+
// Check that target ID exists (if the target is XHTML or SVG)
174+
if (targetIDType == null
175+
&& (MIMEType.SVG.is(targetMimetype) || MIMEType.XHTML.is(targetMimetype)))
173176
{
174177
report.message(MessageId.RSC_012, reference.location.context(reference.url.toString()));
175178
throw new CheckAbortException();
176179
}
180+
177181
switch (reference.type)
178182
{
179183
case SVG_PAINT:

src/test/resources/epub3/06-content-document/content-document-xhtml.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,11 @@ Feature: EPUB 3 — Content Documents — XHTML
523523
And no other errors or warnings are reported
524524

525525

526+
#### Objects
527+
528+
Scenario: Allow fragment identifiers on PDFs
529+
When checking EPUB 'object-pdf-fragment-valid'
530+
Then no errors or warnings are reported
526531

527532
#### Schematron Assertions
528533

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html xmlns:epub="http://www.idpf.org/2007/ops" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>Minimal EPUB</title>
6+
</head>
7+
<body>
8+
<h1>Loomings</h1>
9+
<p>Call me Ishmael.</p>
10+
<object data="test.pdf#view=FitV" type="application/pdf"></object>
11+
</body>
12+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>Minimal Nav</title>
6+
</head>
7+
<body>
8+
<nav epub:type="toc">
9+
<ol>
10+
<li><a href="content_001.xhtml">content 001</a></li>
11+
</ol>
12+
</nav>
13+
</body>
14+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
3+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<dc:title id="title">Minimal EPUB 3.0</dc:title>
5+
<dc:language>en</dc:language>
6+
<dc:identifier id="q">NOID</dc:identifier>
7+
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
8+
</metadata>
9+
<manifest>
10+
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
11+
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
12+
<item id="pdf" href="test.pdf" media-type="application/pdf" fallback="content_001"/>
13+
</manifest>
14+
<spine>
15+
<itemref idref="content_001" />
16+
</spine>
17+
</package>

src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/test.pdf

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
3+
<rootfiles>
4+
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
5+
</rootfiles>
6+
</container>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
application/epub+zip

0 commit comments

Comments
 (0)