From 8eb849250bae7b595bbd0a2de95ef46ab39efb0c Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Mon, 21 Nov 2022 00:17:21 +0100 Subject: [PATCH] feat: no longer check collection `role` This commit suppresses and removes the code of the following checks: - `OPF-068`: checked that a role token were one the defined roles in the collection role registry (see https://idpf.github.io/epub-registries/roles/) - `OPF-069`: checked that a custom role URL did not contain the string "idpf.org". These restrictions were removed in EPUB 3.3. The attribute value is still tokenized, and any URL-looking string (in the shape `scheme:something`) is checked to be a valid URL string. Fix #1350. --- .../epubcheck/messages/DefaultSeverities.java | 4 +-- .../com/adobe/epubcheck/opf/OPFHandler30.java | 26 +++---------------- .../messages/MessageBundle.properties | 6 ++--- .../files/collection-role-url-valid.opf | 8 ++++++ 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java b/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java index 613b8c5b4..aaa61f901 100644 --- a/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java +++ b/src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java @@ -257,8 +257,8 @@ private void initialize() severities.put(MessageId.OPF_065, Severity.ERROR); severities.put(MessageId.OPF_066, Severity.ERROR); severities.put(MessageId.OPF_067, Severity.ERROR); - severities.put(MessageId.OPF_068, Severity.ERROR); - severities.put(MessageId.OPF_069, Severity.ERROR); + severities.put(MessageId.OPF_068, Severity.SUPPRESSED); + severities.put(MessageId.OPF_069, Severity.SUPPRESSED); severities.put(MessageId.OPF_070, Severity.WARNING); severities.put(MessageId.OPF_071, Severity.ERROR); severities.put(MessageId.OPF_072, Severity.USAGE); diff --git a/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java b/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java index a6055fcd4..d5592ff44 100644 --- a/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java +++ b/src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java @@ -407,36 +407,16 @@ private List processCollectionRole(String roleAtt) if (URLUtils.isAbsoluteURLString(role)) { // Role is an absolute IRI - // check that the host component doesn't contain 'idpf.org' try { - URL url = URL.parse(role); - if (url.authority() != null && url.authority().contains("idpf.org")) - { - report.message(MessageId.OPF_069, location(), role); - } - else - { - rolesBuilder.add(role); - } + URL.parse(role); } catch (GalimatiasParseException e) { report.message(MessageId.OPF_070, location(), role); + break; } } - else - { - // Role is a NMTOKEN - // Check that it's in the reserved role list - if (ResourceCollection.Roles.fromString(role).isPresent()) - { - rolesBuilder.add(role); - } - else - { - report.message(MessageId.OPF_068, location(), role); - } - } + rolesBuilder.add(role); } return rolesBuilder.build(); } diff --git a/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties b/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties index 462b671af..638f73a0a 100644 --- a/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties +++ b/src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties @@ -247,9 +247,9 @@ OPF_064=OPF declares type "%1$s", validating using profile "%2$s". OPF_065=Invalid metadata declaration, probably due to a cycle in "refines" metadata. OPF_066=Missing "dc:source" or "source-of" pagination metadata. The pagination source must be identified using the "dc:source" and "source-of" properties when the content includes page break markers. OPF_067=The resource "%1$s" must not be listed both as a "link" element in the package metadata and as a manifest item. -OPF_068=Unknown collection role "%1$s". -OPF_069=Custom collection role URI "%1$s" must not include the string "idpf.org" in its host component. -OPF_070=Custom collection role "%1$s" is an invalid URI. +OPF_068= +OPF_069= +OPF_070=Custom collection role "%1$s" is an invalid URL. OPF_071=Index collections must only contain resources pointing to XHTML Content Documents. OPF_072=Metadata element "%1$s" is empty. OPF_073=External identifiers must not appear in the document type declaration. diff --git a/src/test/resources/epub3/05-package-document/files/collection-role-url-valid.opf b/src/test/resources/epub3/05-package-document/files/collection-role-url-valid.opf index ad7dad5eb..9d57e9079 100644 --- a/src/test/resources/epub3/05-package-document/files/collection-role-url-valid.opf +++ b/src/test/resources/epub3/05-package-document/files/collection-role-url-valid.opf @@ -16,4 +16,12 @@ + + + + + + + +