Skip to content

Commit

Permalink
Merge pull request #905 from openpreserve/karenhanson-update-to-epub-…
Browse files Browse the repository at this point in the history
…5-0-1

FIX: Bump ePub -> 1.3 in test audit.
  • Loading branch information
carlwilson authored Mar 4, 2024
2 parents 75bc971 + f4d4f13 commit 44060dc
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 36 deletions.
3 changes: 3 additions & 0 deletions jhove-bbt/scripts/create-1.29-target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ echo "TEST BASELINE: Creating baseline"
# Simply copy baseline for now we're not making any changes
echo " - copying ${baselineRoot} baseline to ${targetRoot}"
cp -R "${baselineRoot}" "${targetRoot}"

# Update release details for ePub module
find "${targetRoot}" -type f -name "audit.jhove.xml" -exec sed -i 's/^ <module release="1.2">EPUB-ptc<\/module>$/ <module release="1.3">EPUB-ptc<\/module>/' {} \;
2 changes: 1 addition & 1 deletion jhove-ext-modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<jwat.version>1.0.3</jwat.version>
<epubcheck.version>4.2.6</epubcheck.version>
<epubcheck.version>5.1.0</epubcheck.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public class EpubModule extends ModuleBase {
private static final String FORMATNAME = "EPUB";

private static final String NAME = "EPUB-ptc";
private static final String RELEASE = "1.2";
private static final int[] DATE = { 2023, 03, 16 };
private static final String RIGHTS_YEAR = "2019";
private static final String RELEASE = "1.3";
private static final int[] DATE = { 2023, 06, 12 };
private static final String RIGHTS_YEAR = "2023";
private static final String[] FORMAT = { FORMATNAME };
private static final String COVERAGE = FORMATNAME;
private static final String[] MIMETYPE = { EPUB_MEDIATYPE };
Expand All @@ -94,18 +94,18 @@ public class EpubModule extends ModuleBase {
private static final String NOTE = "This module uses EPUBCheck for testing of EPUB files.";

// EPUB agent information
private static final String EPUB_AGENTNAME = "International Digital Publishing Forum";
private static final String EPUB_AGENTNAME = "International Digital Publishing Forum and World Wide Web Consortium";
private static final AgentType EPUB_AGENTTYPE = AgentType.STANDARD;
private static final String EPUB_AGENTADDRESS = "International Digital Publishing Forum (IDPF), "
+ "113 Cherry Street, Suite 70-719, Seattle, WA 98104";
private static final String EPUB_AGENTWEBSITE = "http://idpf.org";
private static final String EPUB_AGENTEMAIL = "membership@idpf.org";
private static final String EPUB_AGENTPHONE = "+1-206-451-7250";
private static final String EPUB_AGENTADDRESS = "W3C Inc, "
+ "401 Edgewater Place, Suite 600, Wakefield, MA 01880, USA";
private static final String EPUB_AGENTWEBSITE = "https://www.w3.org/";
private static final String EPUB_AGENTEMAIL = "membership@w3.org";
private static final String EPUB_AGENTPHONE = "+1-339-273-2711";

// EPUB format doc information
private static final String EPUB_FORMATDOCTITLE = FORMATNAME;
private static final String EPUB_FORMATDOCDATE = "2019-05-15";
private static final String EPUB_FORMATDOCURL = "http://www.idpf.org/epub/dir/";
private static final String EPUB_FORMATDOCDATE = "2023-05-25";
private static final String EPUB_FORMATDOCURL = "https://www.w3.org/TR/epub/";

// Signatures
private static final String EPUB_EXTENSION = ".epub";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class JhoveRepInfoReport extends MasterReport {
protected static final String ISO_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'";
protected static final String FALLBACK_FORMAT = "application/octet-stream";

protected static final String FRAGMENT_START = "#";

public JhoveRepInfoReport(String ePubName) {
this.setEpubFileName(PathUtil.removeWorkingDirectory(ePubName));

Expand Down Expand Up @@ -146,7 +148,8 @@ public void info(String resource, FeatureEnum feature, String value) {
this.references.add(value);
break;
case RESOURCE:
this.resources.add(value);
String no_fragment = value.split(FRAGMENT_START)[0];
this.resources.add(no_fragment);
break;
case DC_LANGUAGE:
this.language = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class EpubModuleTest {
private static final String EPUB3_TITLE_ENCODING = "src/test/resources/epub/epub3-multiple-renditions.epub";

private static final String EXPECTED_MEDIATYPE = "application/epub+zip";
private static final String EXPECTED_VERSION_3_2 = "3.2";
private static final String EXPECTED_VERSION_3_3 = "3.3";
private static final String PNG_MIMETYPE = "image/png";
private static final String XHTML_MIMETYPE = "application/xhtml+xml";
private static final String NCX_MIMETYPE = "application/x-dtbncx+xml";
Expand All @@ -99,9 +99,11 @@ public void parseValidEpub3PropertiesTest() throws Exception {
assertEquals(0, info.getMessage().size()); // no errors
assertEquals("EPUB", info.getFormat());
assertEquals(EXPECTED_MEDIATYPE, info.getMimeType());
assertEquals(EXPECTED_VERSION_3_2, info.getVersion());
assertEquals(EXPECTED_VERSION_3_3, info.getVersion());
// these may change, so just check they aren't null
assertNotNull(info.getCreated());
// note: this property is missing in 5.1.0 of epubcheck but
// due for fix in next maintence release, uncomment when fixed.
//assertNotNull(info.getCreated());
assertNotNull(info.getLastModified());

Property metadata = info.getProperty(EPUBMETADATA_KEY);
Expand Down Expand Up @@ -248,7 +250,9 @@ public void parseValidEpub2PropertiesTest() throws Exception {
assertEquals(EXPECTED_MEDIATYPE, info.getMimeType());
assertEquals("2.0.1", info.getVersion());
// may change, so just check it isn't null
assertNotNull(info.getCreated());
// note: this property is missing in 5.1.0 of epubcheck but
// due for fix in next maintence release, uncomment when fixed.
//assertNotNull(info.getCreated());

Property metadata = info.getProperty(EPUBMETADATA_KEY);
Map<String, Object> props = toMap(metadata);
Expand Down Expand Up @@ -397,7 +401,7 @@ public void parseImproperlyCompressedEpubTest() throws Exception {
File epubFile = new File(ZIPPED_EPUB_FILEPATH);
RepInfo info = parseAndCheckValidity(epubFile, RepInfo.FALSE, RepInfo.FALSE);
assertEquals(EXPECTED_MEDIATYPE, info.getMimeType());
assertEquals(EXPECTED_VERSION_3_2, info.getVersion());
assertEquals(EXPECTED_VERSION_3_3, info.getVersion());
assertEquals(1, info.getMessage().size());
assertEquals("PKG-006", info.getMessage().get(0).getId());
}
Expand Down Expand Up @@ -425,7 +429,7 @@ public void parseNonEpubTest() throws Exception {
File epubFile = new File(WRONG_EXT_NOT_AN_EPUB_FILEPATH);
RepInfo info = parseAndCheckValidity(epubFile, RepInfo.FALSE, RepInfo.FALSE);
List<Message> msgs = info.getMessage();
final int expectedNumMessages = 3;
final int expectedNumMessages = 2;
assertEquals(expectedNumMessages, msgs.size());
}

Expand All @@ -451,7 +455,7 @@ public void parseNonEpubWithEpubExtensionTest() throws Exception {
RepInfo info = parseAndCheckValidity(epubFile, RepInfo.FALSE, RepInfo.FALSE);
assertEquals(OCTET_MIMETYPE, info.getMimeType());
List<Message> msgs = info.getMessage();
final int expectedNumMessages = 3;
final int expectedNumMessages = 2;
assertEquals(expectedNumMessages, msgs.size());
}

Expand Down Expand Up @@ -508,7 +512,7 @@ public void parseEpubWithMissingFontsTest() throws Exception {
Map<String, Object> fontinfo = new HashMap<String, Object>();
font.forEach(f -> fontinfo.put(f.getName(), f.getValue()));

// only one font in this file, listed but missing.
// a single font file is listed - it is supposed to be embedded but is missing.
assertEquals("Courier", fontinfo.get(PROPNAME_FONTNAME));
assertEquals(true, fontinfo.get(PROPNAME_FONTFILE));

Expand Down Expand Up @@ -579,18 +583,12 @@ public void parseEpubMissingOpfTest() throws Exception {
File epubFile = new File(EPUB2_MISSING_OPF_FILEPATH);
RepInfo info = parseAndCheckValidity(epubFile, RepInfo.FALSE, RepInfo.FALSE);

assertEquals(OCTET_MIMETYPE, info.getMimeType());

Set<String> msgCodes = new HashSet<String>();
assertEquals(2, info.getMessage().size());
Message msg1 = info.getMessage().get(0);
Message msg2 = info.getMessage().get(1);
assertTrue(msg1 instanceof ErrorMessage);
msgCodes.add(msg1.getId());
assertTrue(msg2 instanceof ErrorMessage);
msgCodes.add(msg2.getId());
assertEquals(1, info.getMessage().size());
Message msg = info.getMessage().get(0);
assertTrue(msg instanceof ErrorMessage);
msgCodes.add(msg.getId());
assertTrue(msgCodes.contains("OPF-002"));
assertTrue(msgCodes.contains("RSC-001"));
}

/**
Expand Down Expand Up @@ -665,8 +663,8 @@ public void checkSignaturesEpub2WithEncryptionTest() throws Exception {
public void parseEpub3TitleEncodingTest() throws Exception {
File epubFile = new File(EPUB3_TITLE_ENCODING);
String expectedTitle = "महाभारत";
// well formed and valid
RepInfo info = parseAndCheckValidity(epubFile, RepInfo.TRUE, RepInfo.TRUE);
// well formed but not valid (this is inconsequential to the test, we're just checking title)
RepInfo info = parseAndCheckValidity(epubFile, RepInfo.TRUE, RepInfo.FALSE);

Property metadata = info.getProperty(PROPNAME_EPUB_METADATA);
Map<String, Object> props = toMap(metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
Expand Down Expand Up @@ -45,9 +46,10 @@ public class JhoveRepInfoReportTest {
private static final MessageId WARN_MSG_ID = MessageId.CHK_001;
private static final String WARN_MSG = "Consider yourself warned";
private static final String WARN_MSG_SUGGEST = "Don't do it again!";

private EPUBLocation messageLoc = EPUBLocation.create("epub.opf");
private EPUBLocation messageLoc2 = EPUBLocation.create("content.xhtml");

private EPUBLocation messageLoc = EPUBLocation.of(new File("epub.opf"));
private EPUBLocation messageLoc2 = EPUBLocation.of(new File("content.xhtml"));

private String messageArg = "fakearg";


Expand Down

0 comments on commit 44060dc

Please sign in to comment.