From b81a77d07c796a6ba1841b5b375bfa31d16378f6 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Sat, 22 Apr 2023 01:43:48 +0200 Subject: [PATCH] fix: do not check fragment identifiers on PDF references Fix #1482 --- .../references/ResourceReferencesChecker.java | 6 +++++- .../content-document-xhtml.feature | 5 +++++ .../EPUB/content_001.xhtml | 12 ++++++++++++ .../object-pdf-fragment-valid/EPUB/nav.xhtml | 14 ++++++++++++++ .../object-pdf-fragment-valid/EPUB/package.opf | 17 +++++++++++++++++ .../object-pdf-fragment-valid/EPUB/test.pdf | Bin .../META-INF/container.xml | 6 ++++++ .../files/object-pdf-fragment-valid/mimetype | 1 + 8 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/content_001.xhtml create mode 100644 src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/nav.xhtml create mode 100644 src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/package.opf create mode 100644 src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/test.pdf create mode 100644 src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/META-INF/container.xml create mode 100644 src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/mimetype diff --git a/src/main/java/org/w3c/epubcheck/core/references/ResourceReferencesChecker.java b/src/main/java/org/w3c/epubcheck/core/references/ResourceReferencesChecker.java index 8169de7a1..214750a42 100755 --- a/src/main/java/org/w3c/epubcheck/core/references/ResourceReferencesChecker.java +++ b/src/main/java/org/w3c/epubcheck/core/references/ResourceReferencesChecker.java @@ -169,11 +169,15 @@ else if (MIMEType.SVG.is(targetMimetype) && !fragment.isValid()) { Reference.Type targetIDType = resourceRegistry.getIDType(fragment.getId(), targetResource); - if (targetIDType == null) + + // Check that target ID exists (if the target is XHTML or SVG) + if (targetIDType == null + && (MIMEType.SVG.is(targetMimetype) || MIMEType.XHTML.is(targetMimetype))) { report.message(MessageId.RSC_012, reference.location.context(reference.url.toString())); throw new CheckAbortException(); } + switch (reference.type) { case SVG_PAINT: diff --git a/src/test/resources/epub3/06-content-document/content-document-xhtml.feature b/src/test/resources/epub3/06-content-document/content-document-xhtml.feature index faf46a1af..28769d1d5 100644 --- a/src/test/resources/epub3/06-content-document/content-document-xhtml.feature +++ b/src/test/resources/epub3/06-content-document/content-document-xhtml.feature @@ -523,6 +523,11 @@ Feature: EPUB 3 — Content Documents — XHTML And no other errors or warnings are reported + #### Objects + + Scenario: Allow fragment identifiers on PDFs + When checking EPUB 'object-pdf-fragment-valid' + Then no errors or warnings are reported #### Schematron Assertions diff --git a/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/content_001.xhtml b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/content_001.xhtml new file mode 100644 index 000000000..9f58a885e --- /dev/null +++ b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + + diff --git a/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/nav.xhtml b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/package.opf b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/package.opf new file mode 100644 index 000000000..3f950dc2e --- /dev/null +++ b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/package.opf @@ -0,0 +1,17 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/test.pdf b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/EPUB/test.pdf new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/META-INF/container.xml b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/mimetype b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/epub3/06-content-document/files/object-pdf-fragment-valid/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file