From f81b4231c1d7ebbe2c8ceaaa13990c104ecb0c6b Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Wed, 21 Dec 2022 15:41:03 +0100 Subject: [PATCH] feat: report as usage container resources not listed in manifest EPUBCheck used to report any resource found in the the container but not listed in the manifest as a warning (since #58 was fixed, in v1.1). But the EPUB specification does not require that. This commit downgrades the severity of `OPF-003` to a usage report. See also #1452 See also w3c/epub-specs#563 --- .../epubcheck/messages/DefaultSeverities.java | 2 +- .../multiple-rendition-publication.feature | 1 - .../META-INF/container.xml | 0 .../OPS/content_001.xhtml | 0 .../OPS/not-in-manifest.txt | 0 .../OPS/package.opf | 0 .../OPS/toc.ncx | 0 .../mimetype | 0 src/test/resources/epub2/opf-publication.feature | 10 ++++++---- .../EPUB/content_001.xhtml | 11 +++++++++++ .../EPUB/nav.xhtml | 14 ++++++++++++++ .../EPUB/not-in-manifest.txt | 0 .../EPUB/package.opf | 16 ++++++++++++++++ .../META-INF/container.xml | 6 ++++++ .../mimetype | 1 + .../05-package-document/package-document.feature | 7 +++++++ .../content-document-css.feature | 1 - .../content-document-xhtml.feature | 1 - 18 files changed, 62 insertions(+), 8 deletions(-) rename src/test/resources/epub2/files/epub/{opf-manifest-resource-undeclared-warning => opf-manifest-resource-undeclared-usage}/META-INF/container.xml (100%) rename src/test/resources/epub2/files/epub/{opf-manifest-resource-undeclared-warning => opf-manifest-resource-undeclared-usage}/OPS/content_001.xhtml (100%) rename src/test/resources/epub2/files/epub/{opf-manifest-resource-undeclared-warning => opf-manifest-resource-undeclared-usage}/OPS/not-in-manifest.txt (100%) rename src/test/resources/epub2/files/epub/{opf-manifest-resource-undeclared-warning => opf-manifest-resource-undeclared-usage}/OPS/package.opf (100%) rename src/test/resources/epub2/files/epub/{opf-manifest-resource-undeclared-warning => opf-manifest-resource-undeclared-usage}/OPS/toc.ncx (100%) rename src/test/resources/epub2/files/epub/{opf-manifest-resource-undeclared-warning => opf-manifest-resource-undeclared-usage}/mimetype (100%) create mode 100644 src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/content_001.xhtml create mode 100644 src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/nav.xhtml create mode 100644 src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/not-in-manifest.txt create mode 100644 src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/package.opf create mode 100644 src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/META-INF/container.xml create mode 100644 src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/mimetype diff --git a/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java b/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java index a007f659c..b6ad4ace9 100644 --- a/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java +++ b/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java @@ -190,7 +190,7 @@ private void initialize() // OPF severities.put(MessageId.OPF_001, Severity.ERROR); severities.put(MessageId.OPF_002, Severity.FATAL); - severities.put(MessageId.OPF_003, Severity.WARNING); + severities.put(MessageId.OPF_003, Severity.USAGE); severities.put(MessageId.OPF_004, Severity.WARNING); severities.put(MessageId.OPF_004a, Severity.ERROR); severities.put(MessageId.OPF_004b, Severity.ERROR); diff --git a/src/test/resources/epub-multiple-renditions/multiple-rendition-publication.feature b/src/test/resources/epub-multiple-renditions/multiple-rendition-publication.feature index 0864681c5..a496c2431 100644 --- a/src/test/resources/epub-multiple-renditions/multiple-rendition-publication.feature +++ b/src/test/resources/epub-multiple-renditions/multiple-rendition-publication.feature @@ -81,7 +81,6 @@ Feature: EPUB Multiple-Rendition ▸ Full Publication Checks Then warning RSC-019 is reported (for the missing metatada.xml file) And warning RSC-017 is reported (for the missing selection attributes) And the message contains 'At least one rendition selection attribute should be specified for each non-first rootfile element' - And warning OPF-003 is reported (for a mapping document without a link in the container.xml file) And no other errors or warnings are reported diff --git a/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/META-INF/container.xml b/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/META-INF/container.xml similarity index 100% rename from src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/META-INF/container.xml rename to src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/META-INF/container.xml diff --git a/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/content_001.xhtml b/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/content_001.xhtml similarity index 100% rename from src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/content_001.xhtml rename to src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/content_001.xhtml diff --git a/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/not-in-manifest.txt b/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/not-in-manifest.txt similarity index 100% rename from src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/not-in-manifest.txt rename to src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/not-in-manifest.txt diff --git a/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/package.opf b/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/package.opf similarity index 100% rename from src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/package.opf rename to src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/package.opf diff --git a/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/toc.ncx b/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/toc.ncx similarity index 100% rename from src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/OPS/toc.ncx rename to src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/OPS/toc.ncx diff --git a/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/mimetype b/src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/mimetype similarity index 100% rename from src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-warning/mimetype rename to src/test/resources/epub2/files/epub/opf-manifest-resource-undeclared-usage/mimetype diff --git a/src/test/resources/epub2/opf-publication.feature b/src/test/resources/epub2/opf-publication.feature index fe50cbc40..20950b0c6 100644 --- a/src/test/resources/epub2/opf-publication.feature +++ b/src/test/resources/epub2/opf-publication.feature @@ -72,10 +72,12 @@ Feature: EPUB 2 ▸ Open Packaging Format ▸ Full Publication Checks Then warning OPF-035 is reported And no other errors or warnings are reported - Scenario: Report a reference to a resource that is not listed in the manifest - When checking EPUB 'opf-manifest-resource-undeclared-warning' - Then warning OPF-003 is reported - And no other errors or warnings are reported + Scenario: Report (usage) a resource that is not listed in the manifest + Given the reporting level is set to usage + When checking EPUB 'opf-manifest-resource-undeclared-usage' + Then usage OPF-003 is reported + But no other usages are reported + And no errors or warnings are reported Scenario: Verify that operating system files (`.DS_STORE`, `thumbs.db`) are ignored (issue 256) When checking EPUB 'opf-manifest-os-files-ignore-valid' diff --git a/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/content_001.xhtml b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/content_001.xhtml new file mode 100644 index 000000000..43a520ea2 --- /dev/null +++ b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/content_001.xhtml @@ -0,0 +1,11 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/nav.xhtml b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/not-in-manifest.txt b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/not-in-manifest.txt new file mode 100644 index 000000000..e69de29bb diff --git a/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/package.opf b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/package.opf new file mode 100644 index 000000000..0d1eec6e9 --- /dev/null +++ b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/EPUB/package.opf @@ -0,0 +1,16 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/META-INF/container.xml b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/mimetype b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/epub3/05-package-document/files/manifest-not-listing-container-resource-usage/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/epub3/05-package-document/package-document.feature b/src/test/resources/epub3/05-package-document/package-document.feature index 909a1b3bf..9542433bd 100644 --- a/src/test/resources/epub3/05-package-document/package-document.feature +++ b/src/test/resources/epub3/05-package-document/package-document.feature @@ -412,6 +412,13 @@ Feature: EPUB 3 — Package document When checking EPUB 'package-remote-font-undeclared-error' Then error RSC-008 is reported And no other errors or warnings are reported + + Scenario: Report (usage) a container resource that is not listed in the manifest + Given the reporting level is set to usage + When checking EPUB 'manifest-not-listing-container-resource-usage' + Then usage OPF-003 is reported + But no other usages are reported + And no errors or warnings are reported ### 5.6.2 The item element diff --git a/src/test/resources/epub3/06-content-document/content-document-css.feature b/src/test/resources/epub3/06-content-document/content-document-css.feature index 7fc9638f8..6bd9677ce 100644 --- a/src/test/resources/epub3/06-content-document/content-document-css.feature +++ b/src/test/resources/epub3/06-content-document/content-document-css.feature @@ -76,7 +76,6 @@ Feature: EPUB 3 — Content Documents — CSS Scenario: Report an attempt to `@import` a CSS file that is not declared in the manifest but is present in the container When checking EPUB 'content-css-import-not-declared-error' Then error RSC-008 is reported - And warning OPF-003 is reported And no other errors or warnings are reported @spec @xref:sec-container-iri @xref:sec-manifest-elem 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 b82e2d1b0..535ca7e9b 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 @@ -335,7 +335,6 @@ Feature: EPUB 3 — Content Documents — XHTML Scenario: Report references to undeclared resources in `img srcset` When checking EPUB 'content-xhtml-img-srcset-undeclared-error' Then error RSC-008 is reported (undeclared resource in srcset) - And warning OPF-003 is reported (undeclared resource in container) And no other errors or warnings are reported Scenario: Allow an `img` element with a video resource