From 14e49617c68b5b578c352f4ffedd945a189cff38 Mon Sep 17 00:00:00 2001 From: Yay295 Date: Tue, 3 Sep 2024 09:03:37 -0500 Subject: [PATCH] add some comments --- src/PIL/EpsImagePlugin.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PIL/EpsImagePlugin.py b/src/PIL/EpsImagePlugin.py index c7b1f216494..9e739974181 100644 --- a/src/PIL/EpsImagePlugin.py +++ b/src/PIL/EpsImagePlugin.py @@ -310,6 +310,11 @@ def read_comment(s: str) -> bool: # Check for an "ImageData" descriptor # https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096 + # If we've already read an "ImageData" descriptor, don't read another one. + if imagedata_size: + bytes_read = 0 + continue + # Values: # columns # rows @@ -320,10 +325,6 @@ def read_comment(s: str) -> bool: # binary/ascii (1: binary, 2: ascii) # data start identifier (the image data follows after a single line # consisting only of this quoted value) - if imagedata_size: - bytes_read = 0 - continue - image_data_values = byte_arr[11:bytes_read].split(None, 7) columns, rows, bit_depth, mode_id = ( int(value) for value in image_data_values[:4] @@ -339,6 +340,8 @@ def read_comment(s: str) -> bool: else: break + # Read the columns and rows after checking the bit depth and mode + # in case the bit depth and/or mode are invalid. imagedata_size = columns, rows elif bytes_mv[:5] == b"%%EOF": break