diff --git a/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java b/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java index 249b7f3f4..7b6e56ed7 100644 --- a/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java +++ b/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java @@ -300,6 +300,7 @@ private void initialize() severities.put(MessageId.PKG_022, Severity.WARNING); severities.put(MessageId.PKG_023, Severity.USAGE); severities.put(MessageId.PKG_024, Severity.INFO); + severities.put(MessageId.PKG_025, Severity.ERROR); // Resources severities.put(MessageId.RSC_001, Severity.ERROR); diff --git a/src/main/java/com/adobe/epubcheck/messages/MessageId.java b/src/main/java/com/adobe/epubcheck/messages/MessageId.java index e8b9c438d..5822f946b 100644 --- a/src/main/java/com/adobe/epubcheck/messages/MessageId.java +++ b/src/main/java/com/adobe/epubcheck/messages/MessageId.java @@ -294,6 +294,7 @@ public enum MessageId implements Comparable PKG_022("PKG-022"), PKG_023("PKG-023"), PKG_024("PKG-024"), + PKG_025("PKG-025"), // Messages relating to resources RSC_001("RSC-001"), diff --git a/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java b/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java index 8835634de..2ef4e06cb 100644 --- a/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java +++ b/src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java @@ -86,6 +86,11 @@ protected boolean checkContent() @Override protected void checkItem(OPFItem item, OPFHandler opfHandler) { + if (item.getPath().startsWith("META-INF/")) { + report.message(MessageId.PKG_025, + EPUBLocation.create(path, item.getLineNumber(), item.getColumnNumber())); + } + String mimeType = item.getMimeType(); if (mimeType == null || mimeType.equals("")) { diff --git a/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties b/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties index 9ce0808e7..092f2cb2e 100644 --- a/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties +++ b/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties @@ -312,6 +312,7 @@ PKG_022=Wrong file extension for image. The image is a "%1$s" file but has the f PKG_023=Validating the EPUB against version 2.0, default validation profile will be used. PKG_024=Uncommon EPUB file extension. PKG_024_SUG=For maximum compatibility, use ".epub". +PKG_025=Publication resource must not be located in the META-INF directory #Resources RSC_001=File "%1$s" could not be found. diff --git a/src/test/resources/epub3/container-publication.feature b/src/test/resources/epub3/container-publication.feature index 3610294fa..1f27ad886 100644 --- a/src/test/resources/epub3/container-publication.feature +++ b/src/test/resources/epub3/container-publication.feature @@ -42,6 +42,11 @@ Feature: EPUB 3 ▸ Open Container Format ▸ Full Publication Checks Then error PKG-007 is reported And no other errors or warnings are reported + Scenario: Report publication resources found in META-INF + When checking EPUB 'ocf-meta-inf-with-publication-resource-error' + Then error PKG-025 is reported + And no other errors or warnings are reported + ### 3.4 File Names diff --git a/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/content_001.xhtml b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/content_001.xhtml new file mode 100644 index 000000000..5a479735c --- /dev/null +++ b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/content_001.xhtml @@ -0,0 +1,12 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + + diff --git a/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/nav.xhtml b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/package.opf b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/EPUB/package.opf new file mode 100644 index 000000000..85c35a7af --- /dev/null +++ b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/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/files/epub/ocf-meta-inf-with-publication-resource-error/META-INF/container.xml b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/META-INF/image.jpeg b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/META-INF/image.jpeg new file mode 100644 index 000000000..ff336a51f Binary files /dev/null and b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/META-INF/image.jpeg differ diff --git a/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/mimetype b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/epub3/files/epub/ocf-meta-inf-with-publication-resource-error/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file