Fix `ValueError` with unencrypted metadata values (Fixes #766). (#774)

* Fix crash with unencrypted metadata values (pdfminer#766).

* Explicitly check for length

* Update CHANGELOG.md

Co-authored-by: Pieter Marsman <pietermarsman@gmail.com>
pull/768/head^2
Florian Apolloner 2022-06-26 17:25:30 +02:00 committed by GitHub
parent 1044fc05e8
commit f63e9fbee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed ### Fixed
- `ValueError` when trying to decrypt empty metadata values ([#766](https://github.com/pdfminer/pdfminer.six/issues/766))
- Sphinx errors during building of documentation ([#760](https://github.com/pdfminer/pdfminer.six/pull/760)) - Sphinx errors during building of documentation ([#760](https://github.com/pdfminer/pdfminer.six/pull/760))
- `TypeError` when getting default width of font ([#720](https://github.com/pdfminer/pdfminer.six/issues/720)) - `TypeError` when getting default width of font ([#720](https://github.com/pdfminer/pdfminer.six/issues/720))

View File

@ -138,6 +138,8 @@ def resolve_all(x: object, default: object = None) -> Any:
def decipher_all(decipher: DecipherCallable, objid: int, genno: int, x: object) -> Any: def decipher_all(decipher: DecipherCallable, objid: int, genno: int, x: object) -> Any:
"""Recursively deciphers the given object.""" """Recursively deciphers the given object."""
if isinstance(x, bytes): if isinstance(x, bytes):
if len(x) == 0:
return x
return decipher(objid, genno, x) return decipher(objid, genno, x)
if isinstance(x, list): if isinstance(x, list):
x = [decipher_all(decipher, objid, genno, v) for v in x] x = [decipher_all(decipher, objid, genno, v) for v in x]