Skip to content

Commit

Permalink
fix: disallow epub:prefix on embedded SVG
Browse files Browse the repository at this point in the history
Fix #1535
  • Loading branch information
rdeltour committed Dec 23, 2024
1 parent ddb3676 commit 623f5ad
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ include "./mod/epub-xhtml-svg-mathml.rnc" {

# Allow `body` element as a child of `foreignObject`
svg.foreignObject.inner |= body.elem

# Allow `epub:prefix` attribute on `svg` root
svg.attrs &= epub.prefix.attr.ns?
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
svg =
element svg { svg.inner & svg.attrs }
svg.attrs =
( svg.epubtype.allowed.attrs
& epub.prefix.attr.ns?
)
( svg.epubtype.allowed.attrs )
svg.inner =
( svg.any.inner )

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en"
lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
</head>
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
<svg xmlns="http://www.w3.org/2000/svg" epub:prefix="my: http://example.org/vocab/">
<title>SVG</title>
<desc>Description</desc>
<circle r="10"/>
</svg>
</body>
</html>
9 changes: 9 additions & 0 deletions src/test/resources/epub3/D-vocabularies/vocabularies.feature
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,22 @@ Feature: EPUB 3 — Vocabularies — Vocabulary association

Rule: EPUB creators MUST only specify the `prefix` attribute on the root element of the respective format.

Note that for SVG embedded by inclusion, prefixes MUST be declared on the root html element.

@spec @xref:sec-prefix-attr
Example: Report a `prefix` attribute on an XHTML `head` element
When checking file 'prefix-attribute-on-head-error.xhtml'
Then error RSC-005 is reported
And the message contains 'attribute "epub:prefix" not allowed here'
And no other errors or warnings are reported

@spec @xref:sec-prefix-attr
Example: Report a `prefix` attribute on an XHTML embedded `svg` element
When checking file 'prefix-attribute-on-svg-error.xhtml'
Then error RSC-005 is reported
And the message contains 'attribute "epub:prefix" not allowed here'
And no other errors or warnings are reported


Rule: EPUB creators MUST NOT declare the prefix '_'.

Expand Down

0 comments on commit 623f5ad

Please sign in to comment.