Skip to content

Commit e732068

Browse files
authored
feat: downgrade RSC-004 (cannot decrypt resource) to INFO (#1136)
feat: downgrade RSC-004 (cannot decrypt resource) to INFO An INFO better describes EPUBCheck’s inability to decrypt or de-obfuscate a resource. RSC-004 does not necessarily means the content is invalid, but it means EPUBCheck is unable to process it. - All the incomplete `EncryptionFilter` implementations now accurately report they cannot decrypt related content. - Validation will abort early for encrypted (or obfuscated) files, reporting RSC-004 as an INFO message. Fixes 1077, caused by an attempt to parse an obfuscated SVG document which was falsely assumed decryptable by the lying `EncryptionFilter` (boo).
1 parent 2083f05 commit e732068

File tree

16 files changed

+93
-12
lines changed

16 files changed

+93
-12
lines changed

src/main/java/com/adobe/epubcheck/messages/DefaultSeverities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ private void initialize()
293293
severities.put(MessageId.RSC_001, Severity.ERROR);
294294
severities.put(MessageId.RSC_002, Severity.FATAL);
295295
severities.put(MessageId.RSC_003, Severity.ERROR);
296-
severities.put(MessageId.RSC_004, Severity.ERROR);
296+
severities.put(MessageId.RSC_004, Severity.INFO);
297297
severities.put(MessageId.RSC_005, Severity.ERROR);
298298
severities.put(MessageId.RSC_006, Severity.ERROR);
299299
severities.put(MessageId.RSC_006b, Severity.USAGE);

src/main/java/com/adobe/epubcheck/ocf/AdobeFontManglingFilter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ public AdobeFontManglingFilter(String Uid)
1313

1414
public boolean canDecrypt()
1515
{
16-
//FIXME we force return true to not issue a false-positive warning (see Issue 220)
17-
// ultimately, we need to pass the concatenated publication IDs (encryption key)
16+
//TODO we need to pass the concatenated publication IDs (encryption key)
1817
// and implement de-obfuscation.
19-
return true;
18+
return false;
2019
// return uniqueIdentifier != null;
2120
}
2221

src/main/java/com/adobe/epubcheck/ocf/IDPFFontManglingFilter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ public IDPFFontManglingFilter(String Uid)
1313

1414
public boolean canDecrypt()
1515
{
16-
//FIXME we force return true to not issue a false-positive warning (see Issue 220)
17-
// ultimately, we need to pass the concatenated publication IDs (encryption key)
16+
// TODO we need to pass the concatenated publication IDs (encryption key)
1817
// and implement de-obfuscation.
19-
return true;
18+
return false;
2019
// return uniqueIdentifier != null;
2120
}
2221

src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,7 @@ public void testDuplicateResources()
14121412

14131413
@Test
14141414
public void testEncryption_Unknown(){
1415-
expectedErrors.add(MessageId.RSC_004);
1415+
expectedInfos.add(MessageId.RSC_004);
14161416
testValidateDocument("invalid/encryption-unknown");
14171417
}
14181418

@@ -1472,4 +1472,11 @@ public void testEncryption_DuplicateIDs()
14721472
Collections.addAll(expectedErrors, MessageId.RSC_005, MessageId.RSC_005);
14731473
testValidateDocument("invalid/encryption-duplicate-ids");
14741474
}
1475+
1476+
@Test
1477+
public void testObfuscatedSVG()
1478+
{
1479+
expectedInfos.add(MessageId.RSC_004);
1480+
testValidateDocument("valid/container-obfuscation-svg-valid");
1481+
}
14751482
}

src/test/java/com/adobe/epubcheck/api/Epub30CheckTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public void testValidateEPUB30Issue289()
198198
@Test
199199
public void testValidateEPUB30FontObfuscation()
200200
{
201+
Collections.addAll(expectedInfos, MessageId.RSC_004);
201202
testValidateDocument("valid/font-obfuscation.epub");
202203
}
203204

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
4+
<head>
5+
<title>Minimal EPUB</title>
6+
</head>
7+
<body epub:type="bodymatter">
8+
<h1>Loomings</h1>
9+
<p>Call me Ishmael.</p>
10+
<img src="emoji.svg" alt="a smiling emoji" />
11+
</body>
12+
</html>
7.18 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE html>
3+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
4+
<head>
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+
<nav epub:type="landmarks">
14+
<ol>
15+
<li><a href="content_001.xhtml" epub:type="bodymatter">Start Reading</a></li>
16+
</ol>
17+
</nav>
18+
</body>
19+
</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+
</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="emoji" href="emoji.svg" media-type="image/svg+xml"/>
13+
</manifest>
14+
<spine>
15+
<itemref idref="content_001" />
16+
</spine>
17+
</package>
Lines 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>

0 commit comments

Comments
 (0)