Skip to content

Commit

Permalink
fix: consider all video/* as video media types
Browse files Browse the repository at this point in the history
Previously, only `video/h264`, `video/mp4`, and `video/webm` were
treated as video types.

This change also adds a method `isCommonVideoType(String type)` to
`OPFChecker30.java`, so that usage check OPF_036 can still be made.

See also #469
  • Loading branch information
rdeltour committed Jan 18, 2019
1 parent 91b84ad commit 27ad571
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.adobe.epubcheck.ctc.xml;

import static com.adobe.epubcheck.opf.OPFChecker30.isBlessedAudioType;
import static com.adobe.epubcheck.opf.OPFChecker30.isBlessedVideoType;
import static com.adobe.epubcheck.opf.OPFChecker30.isCommonVideoType;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -203,7 +203,7 @@ public void startElement(String uri, String localName, String qName, Attributes
{
String mimeType = attributes.getValue("type");

if (mimeType == null || !isBlessedVideoType(mimeType))
if (mimeType == null || !isCommonVideoType(mimeType))
{
if (mimeType == null)
{
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/adobe/epubcheck/opf/OPFChecker30.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,13 @@ public static boolean isBlessedAudioType(String type)

public static boolean isBlessedVideoType(String type)
{
return type.startsWith("video/h264") || type.startsWith("video/webm")
|| type.startsWith("video/mp4");
return type.startsWith("video/");
}

public static boolean isCommonVideoType(String type)
{
return "video/h264".equals(type) || "video/webm".equals(type)
|| "video/mp4".equals(type);
}

public static boolean isBlessedFontType(String type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ public void testValidateEPUBPLoremBindings()
}

@Test
public void testValidateEPUBPLoremInvalidBindings()
public void testValidateEPUBPLoremBindingsWithNativeFallback()
{
Collections.addAll(expectedErrors, MessageId.MED_002);
testValidateDocument("invalid/lorem-bindings");
// tests that an object element with both bindings and native fallback is allowed
testValidateDocument("valid/lorem-bindings-withnativefallback");
}

@Test
Expand Down
19 changes: 0 additions & 19 deletions src/test/java/com/adobe/epubcheck/ocf/OCFCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,25 +372,6 @@ public void testInvalidLoremBasic30()
assertTrue(testReport.hasInfoMessage("[format version] 3.0.1"));
}

@Test
public void testInvalidLoremBindings30()
{
ValidationReport testReport = testOcfPackage("/30/expanded/invalid/lorem-bindings/",
EPUBVersion.VERSION_3);
if (1 != testReport.getErrorCount() || 0 != testReport.getWarningCount())
{
outWriter.println(testReport);
}
assertTrue(
testReport.errorList.get(0).message.contains("Object element doesn't provide fallback"));
List<MessageId> errors = new ArrayList<MessageId>();
Collections.addAll(errors, MessageId.MED_002);
assertEquals(errors, testReport.getErrorIds());
assertEquals(0, testReport.getWarningCount());

assertTrue(testReport.hasInfoMessage("[format version] 3.0.1"));
}

@Test
public void testInvalidLoremForeign30()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:identifier id="uid">urn:uuid:550e8400-e29b-41d4-a716-446667441231</dc:identifier>
<dc:title>Lorem Ipsum</dc:title>
<dc:title>Lorem Ipsum</dc:title>
<dc:language>la</dc:language>
<dc:date>2011-09-01</dc:date>
<meta property="dcterms:modified">2011-09-01T17:18:00Z</meta>
</metadata>
</metadata>
<manifest>
<item id="t1" href="lorem.xhtml" properties="nav scripted" media-type="application/xhtml+xml" />
<item id="css" href="lorem.css" media-type="text/css" />
<item id="slideshow" href="slideshow.xml" media-type="application/x-demo-slideshow2" />
<item id="video" href="video.avi" media-type="video/avi" />
<item id="t1" href="lorem.xhtml" properties="nav scripted"
media-type="application/xhtml+xml"/>
<item id="css" href="lorem.css" media-type="text/css"/>
<item id="slideshow" href="slideshow.xml" media-type="application/x-demo-slideshow2"/>
<item id="video" href="video.mp4" media-type="video/mp4"/>
</manifest>
<spine>
<itemref idref="t1" />
</spine>
<bindings>
<mediaType handler="t1"
media-type="application/x-demo-slideshow"/>
<itemref idref="t1"/>
</spine>
<bindings>
<mediaType handler="t1" media-type="application/x-demo-slideshow"/>
</bindings>
</package>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<object type="application/x-demo-slideshow3">
<object data="slideshow.xml" type="application/x-demo-slideshow2">
<video src="video.avi" >
<video src="video.mp4" >

</video>
</object>
Expand Down

0 comments on commit 27ad571

Please sign in to comment.