Skip to content

Commit 8eb8492

Browse files
committed
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.
1 parent c733273 commit 8eb8492

File tree

4 files changed

+16
-28
lines changed

4 files changed

+16
-28
lines changed

src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ private void initialize()
257257
severities.put(MessageId.OPF_065, Severity.ERROR);
258258
severities.put(MessageId.OPF_066, Severity.ERROR);
259259
severities.put(MessageId.OPF_067, Severity.ERROR);
260-
severities.put(MessageId.OPF_068, Severity.ERROR);
261-
severities.put(MessageId.OPF_069, Severity.ERROR);
260+
severities.put(MessageId.OPF_068, Severity.SUPPRESSED);
261+
severities.put(MessageId.OPF_069, Severity.SUPPRESSED);
262262
severities.put(MessageId.OPF_070, Severity.WARNING);
263263
severities.put(MessageId.OPF_071, Severity.ERROR);
264264
severities.put(MessageId.OPF_072, Severity.USAGE);

src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -407,36 +407,16 @@ private List<String> processCollectionRole(String roleAtt)
407407
if (URLUtils.isAbsoluteURLString(role))
408408
{
409409
// Role is an absolute IRI
410-
// check that the host component doesn't contain 'idpf.org'
411410
try
412411
{
413-
URL url = URL.parse(role);
414-
if (url.authority() != null && url.authority().contains("idpf.org"))
415-
{
416-
report.message(MessageId.OPF_069, location(), role);
417-
}
418-
else
419-
{
420-
rolesBuilder.add(role);
421-
}
412+
URL.parse(role);
422413
} catch (GalimatiasParseException e)
423414
{
424415
report.message(MessageId.OPF_070, location(), role);
416+
break;
425417
}
426418
}
427-
else
428-
{
429-
// Role is a NMTOKEN
430-
// Check that it's in the reserved role list
431-
if (ResourceCollection.Roles.fromString(role).isPresent())
432-
{
433-
rolesBuilder.add(role);
434-
}
435-
else
436-
{
437-
report.message(MessageId.OPF_068, location(), role);
438-
}
439-
}
419+
rolesBuilder.add(role);
440420
}
441421
return rolesBuilder.build();
442422
}

src/main/resources/com/adobe/epubcheck/messages/MessageBundle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ OPF_064=OPF declares type "%1$s", validating using profile "%2$s".
247247
OPF_065=Invalid metadata declaration, probably due to a cycle in "refines" metadata.
248248
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.
249249
OPF_067=The resource "%1$s" must not be listed both as a "link" element in the package metadata and as a manifest item.
250-
OPF_068=Unknown collection role "%1$s".
251-
OPF_069=Custom collection role URI "%1$s" must not include the string "idpf.org" in its host component.
252-
OPF_070=Custom collection role "%1$s" is an invalid URI.
250+
OPF_068=
251+
OPF_069=
252+
OPF_070=Custom collection role "%1$s" is an invalid URL.
253253
OPF_071=Index collections must only contain resources pointing to XHTML Content Documents.
254254
OPF_072=Metadata element "%1$s" is empty.
255255
OPF_073=External identifiers must not appear in the document type declaration.

src/test/resources/epub3/05-package-document/files/collection-role-url-valid.opf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@
1616
<collection role="http://example.org/">
1717
<link href="http://example.org/resource"/>
1818
</collection>
19+
<collection role="http://idpf.org.example.org/">
20+
<!-- using 'idpf.org' in the URL authority was forbidden in EPUB 3.2 -->
21+
<link href="http://example.org/resource"/>
22+
</collection>
23+
<collection role="unknown-token">
24+
<!-- using roles not in the role vocab was forbidden in EPUB 3.2 -->
25+
<link href="http://example.org/resource"/>
26+
</collection>
1927
</package>

0 commit comments

Comments
 (0)