Skip to content

Commit f59743a

Browse files
committed
fix: allow unknown alternate style sheet class names
A class name found on a `link` element representing a style sheet was reported as an error when it was not one of the known keyword defined in [EPUB Alternate Style Tags](https://idpf.org/epub/altss-tags/). This commit fixes that by allowing any name in the class attribute. This commit also downgrades `CSS-005` to a usage; it is reported when two mutually-exclusive class names are used on the same link element. EPUB Alternate Style Tags defines these as mutual exclusive names, but it is mostly unimplemeneted and this was never strictly forbidden. Fix #989
1 parent 65263a4 commit f59743a

File tree

7 files changed

+29
-10
lines changed

7 files changed

+29
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void initialize()
7171
severities.put(MessageId.CSS_002, Severity.ERROR);
7272
severities.put(MessageId.CSS_003, Severity.WARNING);
7373
severities.put(MessageId.CSS_004, Severity.ERROR);
74-
severities.put(MessageId.CSS_005, Severity.ERROR);
74+
severities.put(MessageId.CSS_005, Severity.USAGE);
7575
severities.put(MessageId.CSS_006, Severity.USAGE);
7676
severities.put(MessageId.CSS_007, Severity.INFO);
7777
severities.put(MessageId.CSS_008, Severity.ERROR);

src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.adobe.epubcheck.vocab.StagingEdupubVocab;
4747
import com.adobe.epubcheck.vocab.StructureVocab;
4848
import com.adobe.epubcheck.vocab.StructureVocab.EPUB_TYPES;
49+
import com.adobe.epubcheck.vocab.UncheckedVocab;
4950
import com.adobe.epubcheck.vocab.Vocab;
5051
import com.adobe.epubcheck.vocab.VocabUtil;
5152
import com.adobe.epubcheck.xml.model.XMLAttribute;
@@ -69,7 +70,7 @@ public class OPSHandler30 extends OPSHandler
6970
MagazineNavigationVocab.PREFIX, MagazineNavigationVocab.VOCAB, ForeignVocabs.PRISM_PREFIX,
7071
ForeignVocabs.PRISM_VOCAB);
7172
private static Map<String, Vocab> ALTCSS_VOCABS = ImmutableMap.<String, Vocab> of("",
72-
AltStylesheetVocab.VOCAB);
73+
AggregateVocab.of(AltStylesheetVocab.VOCAB, new UncheckedVocab("", "")));
7374
private static Map<String, Vocab> KNOWN_VOCAB_URIS = ImmutableMap.of(MagazineNavigationVocab.URI,
7475
MagazineNavigationVocab.VOCAB, ForeignVocabs.PRISM_URI, ForeignVocabs.PRISM_VOCAB);
7576
private static Set<String> DEFAULT_VOCAB_URIS = ImmutableSet.of(StructureVocab.URI);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CSS_001=The "%1$s" property must not be included in an EPUB Style Sheet.
2727
CSS_002=Empty or NULL reference found.
2828
CSS_003=CSS document is encoded in UTF-16. It should be encoded in UTF-8 instead.
2929
CSS_004=CSS documents must be encoded in UTF-8, detected %1%s;
30-
CSS_005=Conflicting alternate style attributes found: %1$s.
30+
CSS_005=Conflicting alternate style tags found: %1$s.
3131
CSS_006=CSS selector specifies fixed position.
3232
CSS_007=Font-face reference "%1$s" refers to non-standard font type "%2$s".
3333
CSS_008=An error occurred while parsing the CSS: %1$s.

src/test/resources/epub3/06-content-document/content-document-xhtml.feature

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,23 @@ Feature: EPUB 3 — Content Documents — XHTML
367367
#### Links
368368

369369
Scenario: Verify a `link` element with a known alt style tag
370-
When checking document 'link-alt-style-tags-valid.xhtml'
370+
Given the reporting level is set to usage
371+
When checking document 'link-alt-style-tags-known-valid.xhtml'
372+
Then no usages are reported
373+
And no errors or warnings are reported
374+
375+
Scenario: Report a `link` element with an unknown alt style tag
376+
Given the reporting level is set to usage
377+
When checking document 'link-alt-style-tags-unknown-valid.xhtml'
371378
Then no errors or warnings are reported
379+
And no usages are reported
372380

373381
Scenario: Report a `link` element with an unknown alt style tag
374-
When checking document 'link-alt-style-tags-error.xhtml'
375-
Then error OPF-027 is reported
376-
And error CSS-005 is reported
377-
And no other errors or warnings are reported
382+
Given the reporting level is set to usage
383+
When checking document 'link-alt-style-tags-conflict-usage.xhtml'
384+
Then no errors or warnings are reported
385+
And usage CSS-005 is reported
386+
But no other usages are reported
378387

379388
Scenario: Verify `link` elements used to declare alternative stylesheets
380389
When checking document 'link-rel-stylesheet-alternate-valid.xhtml'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>alt style tag css declaration</title>
6+
<link rel="stylesheet" href="horizontal.css" class="day night" />
7+
</head>
8+
<body></body>
9+
</html>

src/test/resources/epub3/06-content-document/files/link-alt-style-tags-error.xhtml renamed to src/test/resources/epub3/06-content-document/files/link-alt-style-tags-unknown-valid.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<title>invalid alt style tag css declaration</title>
6-
<link rel="stylesheet" href="horizontal.css" class="horizontal invalid vertical" />
5+
<title>unknown alt style tag css declaration</title>
6+
<link rel="stylesheet" href="horizontal.css" class="unknown" />
77
</head>
88
<body> </body>
99
</html>

0 commit comments

Comments
 (0)