Skip to content

Commit

Permalink
feat: report empty URL as a schema error instead of HTM-008
Browse files Browse the repository at this point in the history
This change effectively removes `HTM-008` by integrating (the emptyness
part of) the check for valid non-empty URL in the RelaxNG schema.
  • Loading branch information
rdeltour committed Nov 28, 2022
1 parent 419f651 commit e3d3afe
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void initialize()
severities.put(MessageId.HTM_005, Severity.USAGE);
severities.put(MessageId.HTM_006, Severity.SUPPRESSED);
severities.put(MessageId.HTM_007, Severity.WARNING);
severities.put(MessageId.HTM_008, Severity.ERROR);
severities.put(MessageId.HTM_008, Severity.SUPPRESSED);
severities.put(MessageId.HTM_009, Severity.ERROR);
severities.put(MessageId.HTM_010, Severity.USAGE);
severities.put(MessageId.HTM_011, Severity.ERROR);
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java
Original file line number Diff line number Diff line change
Expand Up @@ -678,14 +678,7 @@ protected void processHyperlink(URL href)

protected URL checkResourceURL(String src)
{
if (src == null) return null;
// check that the URL is not empty
// TODO this should be moved to a schema check
if (src.trim().isEmpty())
{
report.message(MessageId.HTM_008, location());
return null;
}
if (src == null || src.trim().isEmpty()) return null;

// parse and check the URL
URL url = checkURL(src);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ HTM_003=External entities are not allowed in EPUB v3 documents. External entity
HTM_004=Irregular DOCTYPE: found "%1$s", expected "%2$s".
HTM_005=An external reference was found.
HTM_007=Empty or whitespace-only value of attribute ssml:ph.
HTM_008=The resource URL must not be empty
HTM_009=The DOCTYPE provided is obsolete or irregular and can be removed.
HTM_010=Namespace uri "%1$s" was found.
HTM_011=Entity is undeclared.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ common.attrs.other =
)

common.data.uri.non-empty =
datatype.IRI
datatype.string.nonempty

common.data.uris =
list { datatype.IRI* }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Feature: EPUB 3 — Content Documents — XHTML

Scenario: Report an `img` element with an empty `src` attribute
When checking document 'img-src-empty-error.xhtml'
Then error HTM-008 is reported
Then error RSC-005 is reported
And no other errors or warnings are reported

Scenario: Report an `img` element with no `alt` attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</head>
<body>
<h1>Test</h1>
<img src="" alt="empty"/>
<img src=" " alt="empty"/>
</body>
</html>

0 comments on commit e3d3afe

Please sign in to comment.