Skip to content

PDF dictionary key must be a name - #9884

Open
radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:pdf_name
Open

PDF dictionary key must be a name#9884
radarhere wants to merge 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

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