Skip to content

Commit

Permalink
feat: report as usage container resources not listed in manifest
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rdeltour committed Dec 21, 2022
1 parent 5bac4f8 commit f81b423
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
10 changes: 6 additions & 4 deletions src/test/resources/epub2/opf-publication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns:epub="http://www.idpf.org/2007/ops" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal EPUB</title>
</head>
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f81b423

Please sign in to comment.