-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: restrict SVG title element to HTML elements
This commit updates the content model of the SVG title element to allow any text or HTML elements, but reject any non-HTML element. - use NVDL to reject non-HTML namespaces - the master XHTML schema is now the NVDL schema - add an element class to include all HTML elements Fix #1342
- Loading branch information
Showing
26 changed files
with
224 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/main/resources/com/adobe/epubcheck/schema/30/epub-svg-30.rnc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
namespace svg = "http://www.w3.org/2000/svg" | ||
|
||
include "./mod/epub-xhtml.rnc" { | ||
include "./mod/epub-xhtml-inc.rnc" { | ||
start = svg | ||
} | ||
include "./mod/epub-mathml3.rnc" | ||
include "./mod/epub-svg-inc.rnc" | ||
|
||
svg.title.content |= common.elem.phrasing | ||
svg.title.content |= common.inner.anyhtml | ||
|
||
svg.foreignObject.content |= | ||
( body.elem | ||
| common.inner.flow | ||
| math | ||
) | ||
|
||
mtext.content |= common.elem.phrasing | ||
mtext.content |= common.elem.phrasing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 33 additions & 2 deletions
35
src/main/resources/com/adobe/epubcheck/schema/30/epub-xhtml-30.nvdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" startMode="html"> | ||
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" | ||
xmlns:svg="http://www.w3.org/2000/svg" startMode="html"> | ||
<mode name="html"> | ||
<namespace ns="http://www.w3.org/1999/xhtml"> | ||
<validate schema="epub-xhtml-30.rnc" schemaType="application/relax-ng-compact-syntax" | ||
useMode="attach"/> | ||
useMode="attach"> | ||
<context path="title" useMode="allowOnlyHTML"/> | ||
</validate> | ||
<validate schema="epub-xhtml-30.sch" useMode="attach"/> | ||
</namespace> | ||
</mode> | ||
<mode name="attach"> | ||
<namespace ns="http://www.w3.org/2000/svg"> | ||
<attach> | ||
<context path="title" useMode="allowOnlyHTML"/> | ||
</attach> | ||
</namespace> | ||
<anyNamespace> | ||
<attach/> | ||
</anyNamespace> | ||
</mode> | ||
<mode name="allowOnlyHTML"> | ||
<namespace ns="http://www.w3.org/1999/xhtml"> | ||
<attach/> | ||
</namespace> | ||
<namespace ns="http://www.idpf.org/2007/ops" match="attributes"> | ||
<attach/> | ||
</namespace> | ||
<namespace ns="http://www.w3.org/1999/xlink" match="attributes"> | ||
<attach/> | ||
</namespace> | ||
<namespace ns="http://www.w3.org/XML/1998/namespace" match="attributes"> | ||
<attach/> | ||
</namespace> | ||
<namespace ns="" match="attributes"> | ||
<attach/> | ||
</namespace> | ||
<anyNamespace match="attributes"> | ||
<allow/> | ||
</anyNamespace> | ||
<anyNamespace> | ||
<reject/> | ||
</anyNamespace> | ||
</mode> | ||
</rules> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/resources/com/adobe/epubcheck/schema/30/mod/epub-xhtml-inc.rnc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# ##################################################################### | ||
## RELAX NG Schema for EPUB HTML 5: For inclusion in master schema # | ||
# ##################################################################### | ||
|
||
## Include the main XHTML schema | ||
|
||
include "./epub-xhtml.rnc" | ||
|
||
## HTML fragments | ||
|
||
# Note: the default HMTL schema does not define such a category, so we | ||
# do our best to include what makes sense here | ||
|
||
common.inner.anyhtml = | ||
html.elem | ||
| body.elem | ||
| common.inner.flow |
4 changes: 2 additions & 2 deletions
4
src/test/resources/epub3/00-minimal/files/minimal/EPUB/content_001.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/test/resources/epub3/06-content-document/files/epubtype-not-allowed-error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
src/test/resources/epub3/06-content-document/files/svg-title-content-not-html-error.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Test</title> | ||
</head> | ||
<body> | ||
<h1>Test</h1> | ||
<svg width="12cm" height="4cm" viewBox="0 0 1200 400" version="1.1" | ||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<title>Test</title> | ||
<desc>Non-HTML content</desc> | ||
<g> | ||
<title><not:html xmlns:not="https://example.org">not HTML</not:html></title> | ||
</g> | ||
<g> | ||
<title><body xmlns="http://www.w3.org/1999/xhtml"> | ||
<svg xmlns="http://www.w3.org/2000/svg"> | ||
<title>Inner SVG</title> | ||
<desc>Disallowed</desc> | ||
</svg> | ||
</body></title> | ||
</g> | ||
</svg> | ||
</body> | ||
</html> |
35 changes: 35 additions & 0 deletions
35
src/test/resources/epub3/06-content-document/files/svg-title-content-valid.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Test</title> | ||
</head> | ||
<body> | ||
<h1>Test</h1> | ||
<svg width="12cm" height="4cm" viewBox="0 0 1200 400" version="1.1" | ||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<title>title</title> | ||
<desc>Example</desc> | ||
<g> | ||
<title>Plain text</title> | ||
</g> | ||
<g> | ||
<title><span xmlns="http://www.w3.org/1999/xhtml">html phrasing content</span></title> | ||
</g> | ||
<g> | ||
<title><h1 xmlns="http://www.w3.org/1999/xhtml">html flow content</h1></title> | ||
</g> | ||
<g> | ||
<title><body xmlns="http://www.w3.org/1999/xhtml">html non-categorized elements</body></title> | ||
</g> | ||
<g> | ||
<title>some <span xmlns="http://www.w3.org/1999/xhtml">mixed</span> content</title> | ||
</g> | ||
<g> | ||
<title><html xmlns="http://www.w3.org/1999/xhtml" lang="en"> | ||
<head><title>full html document</title></head><body>…</body></html> | ||
</title> | ||
</g> | ||
</svg> | ||
</body> | ||
</html> |
15 changes: 0 additions & 15 deletions
15
...test/resources/epub3/06-content-document/files/svg-title-not-phrasing-content-error.xhtml
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/test/resources/epub3/06-content-document/files/svg-title-phrasing-content-valid.xhtml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.