Skip to content

PDF dictionary key must be a name - #9884

Merged
radarhere merged 1 commit into
python-pillow:mainfrom
radarhere:pdf_name
Aug 28, 2026
Merged

PDF dictionary key must be a name#9884
radarhere merged 1 commit into
python-pillow:mainfrom
radarhere:pdf_name

Conversation

@radarhere

@radarhere radarhere commented Aug 20, 2026

Copy link
Copy Markdown
Member

Rather than allowing any type of value for a dictionary key

Pillow/src/PIL/PdfParser.py

Lines 881 to 891 in 8bbb9ec

m = cls.re_dict_start.match(data, offset)
if m:
offset = m.end()
result: dict[Any, Any] = {}
m = cls.re_dict_end.match(data, offset)
current_offset: int | None = offset
while not m:
assert current_offset is not None
key, current_offset = cls.get_value(
data, current_offset, max_nesting=max_nesting - 1
)

this PR restricts the key to a name.

https://web.archive.org/web/20211126185945/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/pdf_reference_archives/PDFReference.pdf

A dictionary object is an associative table containing pairs of objects, known as the dictionary's entries. The first element of each entry is the key and the second element is the value. The key must be a name

@radarhere
radarhere merged commit 84b7a5c into python-pillow:main Aug 28, 2026
50 checks passed
@radarhere
radarhere deleted the pdf_name branch August 28, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant