Skip to content

Commit

Permalink
fix: reject unknown epub: attributes in SVG
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rdeltour committed Dec 23, 2024
1 parent 6ae1d24 commit ddb3676
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
svg =
element svg { svg.inner & svg.attrs }
svg.attrs =
( svg.epubtype.allowed.attrs )
( svg.epubtype.allowed.attrs
& epub.prefix.attr.ns?
)
svg.inner =
( svg.any.inner )

Expand All @@ -35,7 +37,7 @@
svg.generic.attr =
attribute *
- ( id
| epub:type
| epub:*
) { text }

# Attribute list of elements where `epub:type` is allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ Feature: EPUB 3 — Content Documents — SVG
And the message contains '"epub:type" not allowed'
And no other errors or warnings are reported

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


### 6.2.2 SVG requirements

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ddb3676

Please sign in to comment.