Skip to content

Raise SyntaxError for invalid XV thumbnail header line - #10346

Closed
56steve wants to merge 1 commit into
python-pillow:mainfrom
56steve:fix/xvthumb-malformed-header
Closed

56steve wants to merge 1 commit into
python-pillow:mainfrom
56steve:fix/xvthumb-malformed-header

Conversation

@56steve

@56steve 56steve commented Oct 28, 2026

Copy link
Copy Markdown

Opening a file that starts with the XV thumbnail magic but has a missing or non-numeric size line raised a bare ValueError from the unpacking or int() call, instead of the SyntaxError that lets Image.open report UnidentifiedImageError. For example, b"P7 332\n#c\n64\n" fails this way. I now catch that and raise SyntaxError, and added a test for it.

@radarhere

Copy link
Copy Markdown
Member

Your data starts with the identifying P7 332.

_MAGIC = b"P7 332"

def _accept(prefix: bytes) -> bool:
return prefix.startswith(_MAGIC)

So it is in the XVThumb format. Why do you feel that it should raise an UnidentifiedImageError?

@56steve 56steve closed this Oct 28, 2026
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.

2 participants