-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow the
Compression
element in the encryption file
- update the `ocf-encryption-30.rnc` schema to allow the `Compression` element as a child of `EncryptionProperty` - add tests Fix #904
- Loading branch information
1 parent
365e6e6
commit ed6f1c4
Showing
14 changed files
with
219 additions
and
12 deletions.
There are no files selected for viewing
42 changes: 30 additions & 12 deletions
42
src/main/resources/com/adobe/epubcheck/schema/30/ocf-encryption-30.rnc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
default namespace = "urn:oasis:names:tc:opendocument:xmlns:container" | ||
start = element encryption { | ||
grammar { | ||
include "mod/security/Lenient-Encryption11-ghc.rnc" { | ||
start = xenc_EncryptedData | xenc_EncryptedKey | ||
} | ||
xenc_EncryptionMethodOtherParams |= | ||
attribute Algorithm { xsd:anyURI "http://www.idpf.org/2008/embedding" } | ||
xenc_EncryptionAlgorithms |= | ||
xsd:anyURI "http://www.idpf.org/2008/embedding" | ||
}+ | ||
} | ||
default namespace = "urn:oasis:names:tc:opendocument:xmlns:container" | ||
namespace epub_xenc_compress = "http://www.idpf.org/2016/encryption#compression" | ||
namespace xenc = "http://www.w3.org/2001/04/xmlenc#" | ||
|
||
start = | ||
element encryption { | ||
grammar { | ||
include "mod/security/Lenient-Encryption11-ghc.rnc" { | ||
start = xenc_EncryptedData | xenc_EncryptedKey | ||
xenc_EncryptionPropertyType = | ||
mixed { | ||
attribute Target { xsd:anyURI }?, | ||
attribute Id { xenc_IdType }?, | ||
attribute xml:* { text }*, | ||
xenc_EncryptionPropertyContent | ||
} | ||
xenc_anyForeignElement = | ||
element * - (xenc:* | epub_xenc_compress:*) { | ||
mixed { security_anyAttribute*, security_anyElement* } | ||
} | ||
} | ||
xenc_EncryptionMethodOtherParams |= attribute Algorithm { xsd:anyURI "http://www.idpf.org/2008/embedding" } | ||
xenc_EncryptionAlgorithms |= xsd:anyURI "http://www.idpf.org/2008/embedding" | ||
xenc_EncryptionPropertyContent = (epub_xenc_Compression & xenc_anyForeignElement*) | xenc_anyForeignElement+ | ||
epub_xenc_Compression = element epub_xenc_compress:Compression { epub_xenc_CompressionType } | ||
epub_xenc_CompressionType = | ||
attribute Method { "0" | "8" }, | ||
attribute OriginalLength { xsd:nonNegativeInteger } | ||
}+ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/test/resources/30/expanded/invalid/ocf-compression/EPUB/content_001.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Minimal EPUB</title> | ||
</head> | ||
<body epub:type="bodymatter"> | ||
<h1>Loomings</h1> | ||
<p>Call me Ishmael.</p> | ||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
src/test/resources/30/expanded/invalid/ocf-compression/EPUB/nav.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Minimal Nav</title> | ||
</head> | ||
<body> | ||
<nav epub:type="toc"> | ||
<ol> | ||
<li><a href="content_001.xhtml">content 001</a></li> | ||
</ol> | ||
</nav> | ||
<nav epub:type="landmarks"> | ||
<ol> | ||
<li><a href="content_001.xhtml" epub:type="bodymatter">Start Reading</a></li> | ||
</ol> | ||
</nav> | ||
</body> | ||
</html> |
16 changes: 16 additions & 0 deletions
16
src/test/resources/30/expanded/invalid/ocf-compression/EPUB/package.opf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
6 changes: 6 additions & 0 deletions
6
src/test/resources/30/expanded/invalid/ocf-compression/META-INF/container.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
23 changes: 23 additions & 0 deletions
23
src/test/resources/30/expanded/invalid/ocf-compression/META-INF/encryption.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<encryption xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:enc="http://www.w3.org/2001/04/xmlenc#" | ||
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<enc:EncryptedKey Id="EK"> | ||
<enc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/> | ||
<ds:KeyInfo> | ||
<ds:KeyName>John Smith</ds:KeyName> | ||
</ds:KeyInfo> | ||
<enc:CipherData> | ||
<enc:CipherValue>d2hhdCBkaWQgeW91IHRoaW5rIHlvdSdkIGZpbmQ/</enc:CipherValue> | ||
</enc:CipherData> | ||
</enc:EncryptedKey> | ||
<enc:EncryptedData Id="ED1"> | ||
<enc:CipherData> | ||
<enc:CipherReference URI="OEPBS/video.mp4"/> | ||
</enc:CipherData> | ||
<enc:EncryptionProperties> | ||
<enc:EncryptionProperty xmlns:ns="http://www.idpf.org/2016/encryption#compression"> | ||
<ns:Compression Method="3" OriginalLength=""/> | ||
</enc:EncryptionProperty> | ||
</enc:EncryptionProperties> | ||
</enc:EncryptedData> | ||
</encryption> |
1 change: 1 addition & 0 deletions
1
src/test/resources/30/expanded/invalid/ocf-compression/mimetype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
application/epub+zip |
11 changes: 11 additions & 0 deletions
11
src/test/resources/30/expanded/valid/ocf-compression/EPUB/content_001.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Minimal EPUB</title> | ||
</head> | ||
<body epub:type="bodymatter"> | ||
<h1>Loomings</h1> | ||
<p>Call me Ishmael.</p> | ||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
src/test/resources/30/expanded/valid/ocf-compression/EPUB/nav.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Minimal Nav</title> | ||
</head> | ||
<body> | ||
<nav epub:type="toc"> | ||
<ol> | ||
<li><a href="content_001.xhtml">content 001</a></li> | ||
</ol> | ||
</nav> | ||
<nav epub:type="landmarks"> | ||
<ol> | ||
<li><a href="content_001.xhtml" epub:type="bodymatter">Start Reading</a></li> | ||
</ol> | ||
</nav> | ||
</body> | ||
</html> |
16 changes: 16 additions & 0 deletions
16
src/test/resources/30/expanded/valid/ocf-compression/EPUB/package.opf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
6 changes: 6 additions & 0 deletions
6
src/test/resources/30/expanded/valid/ocf-compression/META-INF/container.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
23 changes: 23 additions & 0 deletions
23
src/test/resources/30/expanded/valid/ocf-compression/META-INF/encryption.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<encryption xmlns="urn:oasis:names:tc:opendocument:xmlns:container" xmlns:enc="http://www.w3.org/2001/04/xmlenc#" | ||
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> | ||
<enc:EncryptedKey Id="EK"> | ||
<enc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/> | ||
<ds:KeyInfo> | ||
<ds:KeyName>John Smith</ds:KeyName> | ||
</ds:KeyInfo> | ||
<enc:CipherData> | ||
<enc:CipherValue>d2hhdCBkaWQgeW91IHRoaW5rIHlvdSdkIGZpbmQ/</enc:CipherValue> | ||
</enc:CipherData> | ||
</enc:EncryptedKey> | ||
<enc:EncryptedData Id="ED1"> | ||
<enc:CipherData> | ||
<enc:CipherReference URI="OEPBS/video.mp4"/> | ||
</enc:CipherData> | ||
<enc:EncryptionProperties> | ||
<enc:EncryptionProperty xmlns:ns="http://www.idpf.org/2016/encryption#compression"> | ||
<ns:Compression Method="8" OriginalLength="3500000"/> | ||
</enc:EncryptionProperty> | ||
</enc:EncryptionProperties> | ||
</enc:EncryptedData> | ||
</encryption> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
application/epub+zip |