mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-22 17:29:56 +06:00
Try to support PDFs with weird spacing in Encrypt blob
Some PDFs apparently use nonstandard spacing in the /Encrypt blob which my parser didn't like. Hopefully this fixes it? Related to #44
This commit is contained in:
parent
4dfc7af7b8
commit
c508280319
@ -128,9 +128,16 @@ def find_enc(filename_in):
|
|||||||
|
|
||||||
for line in br.readlines():
|
for line in br.readlines():
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if "R/Encrypt" in line and "R/ID" in line:
|
is_encrypt_normal = "R/Encrypt" in line and "R/ID" in line
|
||||||
|
is_encrypt_odd = "R" in line and "/Encrypt" in line and "/ID" in line
|
||||||
|
if is_encrypt_normal or is_encrypt_odd:
|
||||||
|
|
||||||
find_enc_end = int(time.time() * 1000)
|
find_enc_end = int(time.time() * 1000)
|
||||||
print("Found ENC after %d attempts - took %d ms" % (i, find_enc_end - find_enc_start))
|
print("Found ENC after %d attempts - took %d ms" % (i, find_enc_end - find_enc_start))
|
||||||
|
if is_encrypt_odd:
|
||||||
|
print("Odd formatting of encryption blob?")
|
||||||
|
print("If this doesn't work correctly please open a bug report.")
|
||||||
|
|
||||||
return line
|
return line
|
||||||
|
|
||||||
find_enc_end = int(time.time() * 1000)
|
find_enc_end = int(time.time() * 1000)
|
||||||
@ -186,7 +193,7 @@ def patch_drm_into_pdf(filename_in, adept_license_string, filename_out, ebx_book
|
|||||||
line_split = encrypt.split(' ')
|
line_split = encrypt.split(' ')
|
||||||
next = 0
|
next = 0
|
||||||
for element in line_split:
|
for element in line_split:
|
||||||
if element == "R/Encrypt":
|
if element == "R/Encrypt" or element == "/Encrypt":
|
||||||
next = 2
|
next = 2
|
||||||
continue
|
continue
|
||||||
if next == 2:
|
if next == 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user