Skip to content

Commit

Permalink
fix: consider HTML form elements as scripted content
Browse files Browse the repository at this point in the history
Fixes #1282
  • Loading branch information
rdeltour committed Nov 27, 2022
1 parent 312ef5f commit 1bae7f7
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ else if (EpubConstants.HtmlNamespaceUri.equals(e.getNamespace()) && name.equals(
{
processMeta();
}
else if (name.equals("form"))
{
requiredProperties.add(ITEM_PROPERTIES.SCRIPTED);
}
else if (name.equals("link"))
{
processLink();
Expand Down Expand Up @@ -538,7 +542,8 @@ protected void processVideo()
protected void processHyperlink(URL href)
{
super.processHyperlink(href);
if ("data".equals(href.scheme())) {
if ("data".equals(href.scheme()))
{
report.message(MessageId.RSC_029, location());
return;
}
Expand Down Expand Up @@ -912,7 +917,7 @@ protected void checkOverlaysStyles()
if (context.opfItem.isPresent() && context.opfItem.get().getMediaOverlay() != null
&& (context.featureReport.hasFeature(FeatureEnum.MEDIA_OVERLAYS_ACTIVE_CLASS)
|| context.featureReport.hasFeature(FeatureEnum.MEDIA_OVERLAYS_PLAYBACK_ACTIVE_CLASS))
&& !this.hasCSS)
&& !this.hasCSS)
{
report.message(MessageId.CSS_030, location());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<title>Minimal EPUB</title>
</head>
<body>
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
<form action="https://example.org" method="get">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required="" />
<input type="submit" value="Subscribe!" />
</form>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!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>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,14 @@ Feature: EPUB 3 — Package document
And no other errors or warnings are reported

@spec @xref:sec-item-resource-properties
Scenario: Report a scripted document without the `scripted` property declared in the package document
When checking EPUB 'package-manifest-prop-scripted-undeclared-error'
Scenario: Report a scripted document (javascript) without the `scripted` property declared in the package document
When checking EPUB 'package-manifest-prop-scripted-undeclared-javascript-error'
Then error OPF-014 is reported
And no other errors or warnings are reported

@spec @xref:sec-item-resource-properties
Scenario: Report a scripted document (form) without the `scripted` property declared in the package document
When checking EPUB 'package-manifest-prop-scripted-undeclared-form-error'
Then error OPF-014 is reported
And no other errors or warnings are reported

Expand Down

0 comments on commit 1bae7f7

Please sign in to comment.