Skip to content

Commit fc5e360

Browse files
committed
fix: allow decimal viewport dimensions in fixed-layout
The spec only says dimensions must be a "positive number" (or keyword), it does not specifically forbid decimal values. Fix #1481
1 parent b81a77d commit fc5e360

File tree

7 files changed

+58
-2
lines changed

7 files changed

+58
-2
lines changed

src/main/java/org/w3c/epubcheck/util/microsyntax/ViewportMeta.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
public class ViewportMeta
1414
{
15-
private static Pattern VIEWPORT_HEIGHT_REGEX = Pattern.compile("\\d+|device-height");
16-
private static Pattern VIEWPORT_WIDTH_REGEX = Pattern.compile("\\d+|device-width");
15+
private static Pattern VIEWPORT_HEIGHT_REGEX = Pattern.compile("\\d+(\\.\\d+)?|device-height");
16+
private static Pattern VIEWPORT_WIDTH_REGEX = Pattern.compile("\\d+(\\.\\d+)?|device-width");
1717

1818
public static ViewportMeta parse(String string, ErrorHandler errorHandler)
1919
{
@@ -26,6 +26,7 @@ public static boolean isValidProperty(String name, String value)
2626
switch (Preconditions.checkNotNull(name))
2727
{
2828
case "width":
29+
2930
return VIEWPORT_WIDTH_REGEX.matcher(value).matches();
3031
case "height":
3132
return VIEWPORT_HEIGHT_REGEX.matcher(value).matches();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
<meta name="viewport" content="width=600.999,height=1200.5" />
6+
<title>Minimal EPUB</title>
7+
</head>
8+
<body>
9+
<h1>Loomings</h1>
10+
<p>Call me Ishmael.</p>
11+
</body>
12+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
3+
<head>
4+
<meta charset="utf-8"/>
5+
<title>Minimal Nav</title>
6+
</head>
7+
<body>
8+
<nav epub:type="toc">
9+
<ol>
10+
<li><a href="content_001.xhtml">content 001</a></li>
11+
</ol>
12+
</nav>
13+
</body>
14+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<meta property="rendition:layout">pre-paginated</meta>
9+
</metadata>
10+
<manifest>
11+
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
12+
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
13+
</manifest>
14+
<spine>
15+
<itemref idref="content_001" />
16+
</spine>
17+
</package>
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>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
application/epub+zip

src/test/resources/epub3/08-layout/layout.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ Feature: EPUB 3 — Layout Rendering Control
214214
When checking EPUB 'content-fxl-xhtml-viewport-valid'
215215
Then no errors or warnings are reported
216216

217+
@spec @xref:sec-fxl-content-dimensions
218+
Scenario: Verify a fixed-layout XHTML document with non-integer viewport dimensions
219+
When checking EPUB 'content-fxl-xhtml-viewport-float-valid'
220+
Then no errors or warnings are reported
221+
217222
@spec @xref:sec-fxl-content-dimensions
218223
Scenario: Verify a fixed-layout XHTML document with a valid viewport with whitespace
219224
When checking EPUB 'content-fxl-xhtml-viewport-whitespace-valid'

0 commit comments

Comments
 (0)