diff --git a/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java b/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java index 9baca65d5..c66a4d1cb 100644 --- a/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java +++ b/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java @@ -519,7 +519,7 @@ private void processItemProperties(OPFItem.Builder builder, String property, Str mimeType = mimeType.trim(); for (ITEM_PROPERTIES itemProp : itemProps) { - if (!itemProp.allowedOnTypes().contains(mimeType)) + if (!itemProp.isAllowedForType(mimeType)) { report.message(MessageId.OPF_012, location(), ITEM_VOCAB.getName(itemProp), mimeType); } diff --git a/src/main/java/com/adobe/epubcheck/vocab/PackageVocabs.java b/src/main/java/com/adobe/epubcheck/vocab/PackageVocabs.java index a1d0e6d6c..b13509bff 100644 --- a/src/main/java/com/adobe/epubcheck/vocab/PackageVocabs.java +++ b/src/main/java/com/adobe/epubcheck/vocab/PackageVocabs.java @@ -42,7 +42,7 @@ public static enum META_PROPERTIES public static enum ITEM_PROPERTIES { - COVER_IMAGE("image/gif", "image/jpeg", "image/png", "image/svg+xml"), + COVER_IMAGE("image/*"), DATA_NAV("application/xhtml+xml"), DICTIONARY("application/vnd.epub.search-key-map+xml"), GLOSSARY("application/vnd.epub.search-key-map+xml", "application/xhtml+xml"), @@ -59,12 +59,33 @@ public static enum ITEM_PROPERTIES private ITEM_PROPERTIES(String... types) { - this.types = new ImmutableSet.Builder().add(types).build(); + ImmutableSet.Builder builder = new ImmutableSet.Builder(); + for (String type : types) + { + if (type.endsWith("/*")) + { + builder.add(type.substring(0, type.length() - 1)); + } + else + { + builder.add(type); + } + } + this.types = builder.build(); } - public Set allowedOnTypes() + public boolean isAllowedForType(String mimetype) { - return types; + if (mimetype == null) return false; + for (String allowedType : types) + { + if (allowedType.equals(mimetype) + || allowedType.endsWith("/") && mimetype.startsWith(allowedType)) + { + return true; + } + } + return false; } } diff --git a/src/test/resources/epub3/05-package-document/files/item-property-cover-image-webp-valid.opf b/src/test/resources/epub3/05-package-document/files/item-property-cover-image-webp-valid.opf new file mode 100644 index 000000000..34b770c0b --- /dev/null +++ b/src/test/resources/epub3/05-package-document/files/item-property-cover-image-webp-valid.opf @@ -0,0 +1,17 @@ + + + + Title + en + NOID + 2019-01-01T12:00:00Z + + + + + + + + + \ 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 81874c928..7c8b5341b 100644 --- a/src/test/resources/epub3/05-package-document/package-document.feature +++ b/src/test/resources/epub3/05-package-document/package-document.feature @@ -523,6 +523,11 @@ Feature: EPUB 3 — Package document ##### cover-image + @spec @xref:sec-item-resource-properties + Scenario: The 'cover-image' item property is allowed on WebP images + When checking file 'item-property-cover-image-webp-valid.opf' + Then no other errors or warnings are reported + @spec @xref:sec-item-resource-properties Scenario: The 'cover-image' item property must occur at most once When checking file 'item-property-cover-image-multiple-error.opf'