File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -437,3 +437,11 @@ def test_eof_before_bounding_box() -> None:
437437 with pytest .raises (OSError ):
438438 with Image .open ("Tests/images/zero_bb_eof_before_boundingbox.eps" ):
439439 pass
440+
441+
442+ def test_invalid_data_after_eof () -> None :
443+ with open ("Tests/images/illuCS6_preview.eps" , "rb" ) as f :
444+ img_bytes = io .BytesIO (f .read () + b"\r \n %" + (b" " * 255 ))
445+
446+ with Image .open (img_bytes ) as img :
447+ assert img .mode == "RGB"
Original file line number Diff line number Diff line change @@ -356,14 +356,10 @@ def _read_comment(s):
356356
357357 self ._size = columns , rows
358358 return
359+ elif bytes_mv [:5 ] == b"%%EOF" :
360+ break
359361 elif trailer_reached and reading_trailer_comments :
360362 # Load EPS trailer
361-
362- # if this line starts with "%%EOF",
363- # then we've reached the end of the file
364- if bytes_mv [:5 ] == b"%%EOF" :
365- break
366-
367363 s = str (bytes_mv [:bytes_read ], "latin-1" )
368364 _read_comment (s )
369365 elif bytes_mv [:9 ] == b"%%Trailer" :
You can’t perform that action at this time.
0 commit comments