GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: allow SVG/MathML doctype declarations · w3c/epubcheck@6e44b39

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • main/java/com/adobe/epubcheck/xml
      • XMLParser.java
    • test/resources/epub3
      • files/epub
        • xml-external-identifier-allowed-valid
          • EPUB
            • content_001.xhtml
            • mathml-mediatype-1.xml
            • mathml-mediatype-2.xml
            • mathml-mediatype-3.xml
            • nav.xhtml
            • package.opf
            • svg.svg
          • META-INF
            • container.xml
          • mimetype
        • xml-external-identifier-bad-mediatype-error
          • EPUB
            • content_001.xhtml
            • nav.xhtml
            • package.opf
            • toc.ncx
          • META-INF
            • container.xml
          • mimetype
        • xml-external-identifier-disallowed-error
          • EPUB
            • content_001.xhtml
            • nav.xhtml
            • package.opf
            • toc.ncx
          • META-INF
            • container.xml
          • mimetype
      • resources-publication.feature
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/main/java/com/adobe/epubcheck/xml/XMLParser.java‎

Copy file name to clipboardExpand all lines: src/main/java/com/adobe/epubcheck/xml/XMLParser.java
+23-8Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,18 @@ public InputSource resolveEntity(String publicId, String systemId)
313313

314314
String resourcePath = systemIdMap.get(systemId);
315315

316-
if (resourcePath != null)
316+
// external entities are not resolved in EPUB 3
317+
if (context.version == EPUBVersion.VERSION_3 || systemId.equals("about:legacy-compat")) {
318+
return new InputSource(new StringReader(""));
319+
}
320+
else if (resourcePath != null)
317321
{
318322
InputStream resourceStream = ResourceUtil.getResourceStream(resourcePath);
319323
InputSource source = new InputSource(resourceStream);
320324
source.setPublicId(publicId);
321325
source.setSystemId(systemId);
322326
return source;
323327
}
324-
else if (systemId.equals("about:legacy-compat"))
325-
{
326-
// special case
327-
return new InputSource(new StringReader(""));
328-
329-
}
330328
else
331329
{
332330
// check for a system prop that turns off online fetching
@@ -797,7 +795,24 @@ else if (context.version == EPUBVersion.VERSION_3)
797795
}
798796
else if (publicId != null || systemId != null)
799797
{
800-
report.message(MessageId.OPF_073, getLocation());
798+
// check if the declaration is allowed for the current media type
799+
boolean isAllowed;
800+
switch (mimeType)
801+
{
802+
case "image/svg+xml":
803+
isAllowed = "-//W3C//DTD SVG 1.1//EN".equals(publicId) && "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd".equals(systemId);
804+
break;
805+
case "application/mathml+xml":
806+
case "application/mathml-content+xml":
807+
case "application/mathml-presentation+xml":
808+
isAllowed = "-//W3C//DTD MathML 3.0//EN".equals(publicId) && "http://www.w3.org/Math/DTD/mathml3/mathml3.dtd".equals(systemId);
809+
break;
810+
default:
811+
isAllowed= false;
812+
}
813+
if (!isAllowed) {
814+
report.message(MessageId.OPF_073, getLocation());
815+
}
801816
}
802817
}
803818

Collapse file

‎src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/content_001.xhtml‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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>Minimal EPUB</title>
6+
</head>
7+
<body>
8+
<h1>Loomings</h1>
9+
<p>Call me Ishmael.</p>
10+
</body>
11+
</html>
Collapse file

‎src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/mathml-mediatype-1.xml‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "http://www.w3.org/Math/DTD/mathml3/mathml3.dtd">
3+
<math xmlns="http://www.w3.org/1998/Math/MathML" alttext="2x+y-z">
4+
<mrow>
5+
<mn>2</mn>
6+
<mo> &#x2061;<!--INVISIBLE TIMES--></mo>
7+
<mi>x</mi>
8+
</mrow>
9+
<mrow>
10+
<mo>+</mo>
11+
<mi>y</mi>
12+
<mo>-</mo>
13+
<mi>z</mi>
14+
</mrow>
15+
</math>
Collapse file

‎src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/mathml-mediatype-2.xml‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "http://www.w3.org/Math/DTD/mathml3/mathml3.dtd">
3+
<math xmlns="http://www.w3.org/1998/Math/MathML" alttext="2x+y-z">
4+
<mrow>
5+
<mn>2</mn>
6+
<mo> &#x2061;<!--INVISIBLE TIMES--></mo>
7+
<mi>x</mi>
8+
</mrow>
9+
<mrow>
10+
<mo>+</mo>
11+
<mi>y</mi>
12+
<mo>-</mo>
13+
<mi>z</mi>
14+
</mrow>
15+
</math>
Collapse file

‎src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/mathml-mediatype-3.xml‎

Copy file name to clipboard
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "http://www.w3.org/Math/DTD/mathml3/mathml3.dtd">
3+
<math xmlns="http://www.w3.org/1998/Math/MathML" alttext="2x+y-z">
4+
<mrow>
5+
<mn>2</mn>
6+
<mo> &#x2061;<!--INVISIBLE TIMES--></mo>
7+
<mi>x</mi>
8+
</mrow>
9+
<mrow>
10+
<mo>+</mo>
11+
<mi>y</mi>
12+
<mo>-</mo>
13+
<mi>z</mi>
14+
</mrow>
15+
</math>
Collapse file

‎…external-identifier-error/EPUB/nav.xhtml‎ ‎…-identifier-allowed-valid/EPUB/nav.xhtml‎src/test/resources/epub3/files/epub/xml-ncx-doctype-external-identifier-error/EPUB/nav.xhtml renamed to src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/nav.xhtml src/test/resources/epub3/files/epub/xml-ncx-doctype-external-identifier-error/EPUB/nav.xhtml renamed to src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/nav.xhtml

Copy file name to clipboard
File renamed without changes.
Collapse file

‎src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/package.opf‎

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
3+
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
4+
<dc:title id="title">Minimal EPUB 3.0</dc:title>
5+
<dc:language>en</dc:language>
6+
<dc:identifier id="q">NOID</dc:identifier>
7+
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
8+
</metadata>
9+
<manifest>
10+
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
11+
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
12+
<item id="mathml-1" href="mathml-mediatype-1.xml" media-type="application/mathml+xml" fallback="content_001"/>
13+
<item id="mathml-2" href="mathml-mediatype-2.xml" media-type="application/mathml-presentation+xml" fallback="content_001"/>
14+
<item id="mathml-3" href="mathml-mediatype-3.xml" media-type="application/mathml-content+xml" fallback="content_001"/>
15+
<item id="svg" href="svg.svg" media-type="image/svg+xml"/>
16+
</manifest>
17+
<spine>
18+
<itemref idref="content_001" />
19+
<itemref idref="svg"/>
20+
<itemref idref="mathml-1"/>
21+
<itemref idref="mathml-2"/>
22+
<itemref idref="mathml-3"/>
23+
</spine>
24+
</package>
Collapse file

‎src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/EPUB/svg.svg‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/META-INF/container.xml‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
3+
<rootfiles>
4+
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
5+
</rootfiles>
6+
</container>
Collapse file

‎…ctype-external-identifier-error/mimetype‎ ‎…ternal-identifier-allowed-valid/mimetype‎src/test/resources/epub3/files/epub/xml-ncx-doctype-external-identifier-error/mimetype renamed to src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/mimetype src/test/resources/epub3/files/epub/xml-ncx-doctype-external-identifier-error/mimetype renamed to src/test/resources/epub3/files/epub/xml-external-identifier-allowed-valid/mimetype

Copy file name to clipboard
File renamed without changes.

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.