Skip to content

Commit ddb3676

Browse files
committed
fix: reject unknown epub: attributes in SVG
The spec only requires SVG to be well-formed, but one can argue that attributes in the EPUB namespace can only be defined by the EPUB specs and therefore should still be validated. For instance, EPUB already specifies where `epub:type` is allowed in SVG, as a normative statement. This commit updates the persmissive SVG schema to reject all attributes in the `http://www.idpf.org/2007/ops` namespace except the known ones.
1 parent 6ae1d24 commit ddb3676

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-svg-forgiving-inc.rnc

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
svg =
2020
element svg { svg.inner & svg.attrs }
2121
svg.attrs =
22-
( svg.epubtype.allowed.attrs )
22+
( svg.epubtype.allowed.attrs
23+
& epub.prefix.attr.ns?
24+
)
2325
svg.inner =
2426
( svg.any.inner )
2527

@@ -35,7 +37,7 @@
3537
svg.generic.attr =
3638
attribute *
3739
- ( id
38-
| epub:type
40+
| epub:*
3941
) { text }
4042

4143
# Attribute list of elements where `epub:type` is allowed

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

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ Feature: EPUB 3 — Content Documents — SVG
5151
And the message contains '"epub:type" not allowed'
5252
And no other errors or warnings are reported
5353

54+
Scenario: Report an unknown `epub:*` attribute used in SVG
55+
Given the reporting level is set to usage
56+
When checking document 'unknown-epub-attribute-error.svg'
57+
Then error RSC-005 is reported
58+
And the message contains '"epub:unknown" not allowed'
59+
And no other errors or warnings are reported
60+
5461

5562
### 6.2.2 SVG requirements
5663

Loading

0 commit comments

Comments
 (0)