Skip to content

Commit

Permalink
feat: no longer check collection role
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rdeltour committed Nov 27, 2022
1 parent c733273 commit 8eb8492
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 3 additions & 23 deletions src/main/java/com/adobe/epubcheck/opf/OPFHandler30.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,36 +407,16 @@ private List<String> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@
<collection role="http://example.org/">
<link href="http://example.org/resource"/>
</collection>
<collection role="http://idpf.org.example.org/">
<!-- using 'idpf.org' in the URL authority was forbidden in EPUB 3.2 -->
<link href="http://example.org/resource"/>
</collection>
<collection role="unknown-token">
<!-- using roles not in the role vocab was forbidden in EPUB 3.2 -->
<link href="http://example.org/resource"/>
</collection>
</package>

0 comments on commit 8eb8492

Please sign in to comment.