File pypdf_encryption_string_unicode_bug.patch of Package python-pypdf

diff -r 26ab3506f24b pyPdf/pdf.py
--- a/pyPdf/pdf.py	Sun Jan 11 15:32:42 2009 -0700
+++ b/pyPdf/pdf.py	Tue Jan 27 09:22:51 2009 +0100
@@ -1380,7 +1380,11 @@
     m.update(p_entry)
     # 5. Pass the first element of the file's file identifier array to the MD5
     # hash function.
-    m.update(id1_entry)
+    if isinstance(id1_entry, str):
+        m.update(id1_entry)
+    else:
+        m.update(id1_entry.original_bytes)
+
     # 6. (Revision 3 or greater) If document metadata is not being encrypted,
     # pass 4 bytes with the value 0xFFFFFFFF to the MD5 hash function.
     if rev >= 3 and not metadata_encrypt:
@@ -1480,7 +1484,10 @@
     # of the ID entry in the document's trailer dictionary; see Table 3.13 on
     # page 73) to the hash function and finish the hash.  (See implementation
     # note 25 in Appendix H.) 
-    m.update(id1_entry)
+    if isinstance(id1_entry, str):
+        m.update(id1_entry)
+    else:
+        m.update(id1_entry.original_bytes)
     md5_hash = m.digest()
     # 4. Encrypt the 16-byte result of the hash, using an RC4 encryption
     # function with the encryption key from step 1. 
openSUSE Build Service is sponsored by