mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 08:34:23 +08:00
More broadly handle RecursionError, via oss-fuzz
This commit is contained in:
+1
-4
@@ -348,10 +348,7 @@ class Page(Container):
|
||||
parsed["data"] = annot
|
||||
return parsed
|
||||
|
||||
try:
|
||||
raw = resolve_all(self.page_obj.annots) or []
|
||||
except RecursionError:
|
||||
raise MalformedPDFException("Annotations are infinitely recursive.")
|
||||
raw = resolve_all(self.page_obj.annots) or []
|
||||
parsed = list(map(parse, raw))
|
||||
if isinstance(self, CroppedPage):
|
||||
return self._crop_fn(parsed)
|
||||
|
||||
@@ -4,6 +4,8 @@ from pdfminer.pdftypes import PDFObjRef
|
||||
from pdfminer.psparser import PSLiteral
|
||||
from pdfminer.utils import PDFDocEncoding
|
||||
|
||||
from .exceptions import MalformedPDFException
|
||||
|
||||
|
||||
def decode_text(s: Union[bytes, str]) -> str:
|
||||
"""
|
||||
@@ -72,7 +74,10 @@ def resolve_all(x: Any) -> Any:
|
||||
if get_dict_type(resolved) == "Page":
|
||||
return x
|
||||
|
||||
return resolve_all(resolved)
|
||||
try:
|
||||
return resolve_all(resolved)
|
||||
except RecursionError as e:
|
||||
raise MalformedPDFException(e)
|
||||
elif isinstance(x, (list, tuple)):
|
||||
return type(x)(resolve_all(v) for v in x)
|
||||
elif isinstance(x, dict):
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user