From 9ce140287d510792d439ed19059e02f26e848af8 Mon Sep 17 00:00:00 2001 From: Abdulazez Zeinu Ali Date: Sat, 16 May 2026 22:52:48 +0300 Subject: [PATCH] fix: prevent IndexError on empty string in ArrayObject._to_lst lst[0] raises IndexError when lst is the empty string ''. Replace with lst.startswith('/') which returns False for '', falling through to TextStringObject('') as expected. --- pypdf/generic/_data_structures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypdf/generic/_data_structures.py b/pypdf/generic/_data_structures.py index 83f630956f..ec32360aeb 100644 --- a/pypdf/generic/_data_structures.py +++ b/pypdf/generic/_data_structures.py @@ -172,7 +172,7 @@ def _to_lst(self, lst: Any) -> list[Any]: elif isinstance(lst, PdfObject): result = [lst] elif isinstance(lst, str): - if lst[0] == "/": + if lst.startswith("/"): result = [NameObject(lst)] else: result = [TextStringObject(lst)]