You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/09/03 18:40:02 UTC

svn commit: r1839980 - /pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java

Author: tilman
Date: Mon Sep  3 18:40:01 2018
New Revision: 1839980

URL: http://svn.apache.org/viewvc?rev=1839980&view=rev
Log:
PDFBOX-4308: add test

Modified:
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java?rev=1839980&r1=1839979&r2=1839980&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java Mon Sep  3 18:40:01 2018
@@ -211,6 +211,29 @@ public class TestSymmetricKeyEncryption
     }
 
     /**
+     * PDFBOX-4308: test that index colorspace table string doesn't get
+     * corrupted when encrypting. This happened because the table was used by
+     * two dictionaries, and when saving one string ended up as a direct object
+     * and the other (but same java object) ended up as an indirect object.
+     * Encryption used the wrong object number and/or the object was encrypted
+     * twice.
+     *
+     * @throws IOException
+     */
+    public void testPDFBox4308() throws IOException
+    {
+        byte[] inputFileAsByteArray;
+        try (InputStream is = new FileInputStream("target/pdfs/PDFBOX-4308.pdf"))
+        {
+            inputFileAsByteArray = IOUtils.toByteArray(is);
+        }
+        int sizePriorToEncryption = inputFileAsByteArray.length;
+
+        testSymmEncrForKeySize(40, false, sizePriorToEncryption, inputFileAsByteArray,
+                USERPASSWORD, OWNERPASSWORD, permission);
+    }
+
+    /**
      * Protect a document with an embedded PDF with a key and try to reopen it
      * with that key and compare.
      *