keep password api unicode, latin1 or utf-8 is encoded in handler
parent
2260f77b19
commit
14585987c3
|
@ -294,7 +294,7 @@ class PDFStandardSecurityHandler(object):
|
||||||
b'..\x00\xb6\xd0h>\x80/\x0c\xa9\xfedSiz')
|
b'..\x00\xb6\xd0h>\x80/\x0c\xa9\xfedSiz')
|
||||||
supported_revisions = (2, 3)
|
supported_revisions = (2, 3)
|
||||||
|
|
||||||
def __init__(self, docid, param, password=b''):
|
def __init__(self, docid, param, password=''):
|
||||||
self.docid = docid
|
self.docid = docid
|
||||||
self.param = param
|
self.param = param
|
||||||
self.password = password
|
self.password = password
|
||||||
|
@ -366,6 +366,7 @@ class PDFStandardSecurityHandler(object):
|
||||||
return result[:n]
|
return result[:n]
|
||||||
|
|
||||||
def authenticate(self, password):
|
def authenticate(self, password):
|
||||||
|
password = password.encode("latin1")
|
||||||
key = self.authenticate_user_password(password)
|
key = self.authenticate_user_password(password)
|
||||||
if key is None:
|
if key is None:
|
||||||
key = self.authenticate_owner_password(password)
|
key = self.authenticate_owner_password(password)
|
||||||
|
@ -536,7 +537,7 @@ class PDFDocument(object):
|
||||||
if SHA256 is not None:
|
if SHA256 is not None:
|
||||||
security_handler_registry[5] = PDFStandardSecurityHandlerV5
|
security_handler_registry[5] = PDFStandardSecurityHandlerV5
|
||||||
|
|
||||||
def __init__(self, parser, password=b'', caching=True, fallback=True):
|
def __init__(self, parser, password='', caching=True, fallback=True):
|
||||||
"Set the document to use a given PDFParser object."
|
"Set the document to use a given PDFParser object."
|
||||||
self.caching = caching
|
self.caching = caching
|
||||||
self.xrefs = []
|
self.xrefs = []
|
||||||
|
@ -587,7 +588,7 @@ class PDFDocument(object):
|
||||||
|
|
||||||
# _initialize_password(password=b'')
|
# _initialize_password(password=b'')
|
||||||
# Perform the initialization with a given password.
|
# Perform the initialization with a given password.
|
||||||
def _initialize_password(self, password=b''):
|
def _initialize_password(self, password=''):
|
||||||
(docid, param) = self.encryption
|
(docid, param) = self.encryption
|
||||||
if literal_name(param.get('Filter')) != 'Standard':
|
if literal_name(param.get('Filter')) != 'Standard':
|
||||||
raise PDFEncryptionError('Unknown filter: param=%r' % param)
|
raise PDFEncryptionError('Unknown filter: param=%r' % param)
|
||||||
|
|
|
@ -113,7 +113,7 @@ class PDFPage(object):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_pages(klass, fp,
|
def get_pages(klass, fp,
|
||||||
pagenos=None, maxpages=0, password=b'',
|
pagenos=None, maxpages=0, password='',
|
||||||
caching=True, check_extractable=True):
|
caching=True, check_extractable=True):
|
||||||
# Create a PDF parser object associated with the file object.
|
# Create a PDF parser object associated with the file object.
|
||||||
parser = PDFParser(fp)
|
parser = PDFParser(fp)
|
||||||
|
|
|
@ -241,7 +241,7 @@ def main(argv):
|
||||||
objids = []
|
objids = []
|
||||||
pagenos = set()
|
pagenos = set()
|
||||||
codec = None
|
codec = None
|
||||||
password = b''
|
password = ''
|
||||||
dumpall = False
|
dumpall = False
|
||||||
proc = dumppdf
|
proc = dumppdf
|
||||||
outfp = sys.stdout
|
outfp = sys.stdout
|
||||||
|
|
|
@ -27,7 +27,7 @@ def main(argv):
|
||||||
return usage()
|
return usage()
|
||||||
if not args: return usage()
|
if not args: return usage()
|
||||||
# input option
|
# input option
|
||||||
password = b''
|
password = ''
|
||||||
pagenos = set()
|
pagenos = set()
|
||||||
maxpages = 0
|
maxpages = 0
|
||||||
# output option
|
# output option
|
||||||
|
|
Loading…
Reference in New Issue