File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,11 @@ def _open(self) -> None:
230230 trailer_reached = False
231231
232232 def check_required_header_comments () -> None :
233+ """
234+ The EPS specification requires that some headers exist.
235+ This should be checked when the header comments formally end,
236+ when image data starts, or when the file ends, whichever comes first.
237+ """
233238 if "PS-Adobe" not in self .info :
234239 msg = 'EPS header missing "%!PS-Adobe" comment'
235240 raise SyntaxError (msg )
@@ -270,6 +275,8 @@ def _read_comment(s: str) -> bool:
270275 if byte == b"" :
271276 # if we didn't read a byte we must be at the end of the file
272277 if bytes_read == 0 :
278+ if reading_header_comments :
279+ check_required_header_comments ()
273280 break
274281 elif byte in b"\r \n " :
275282 # if we read a line ending character, ignore it and parse what
@@ -365,8 +372,6 @@ def _read_comment(s: str) -> bool:
365372 trailer_reached = True
366373 bytes_read = 0
367374
368- check_required_header_comments ()
369-
370375 if not self ._size :
371376 msg = "cannot determine EPS bounding box"
372377 raise OSError (msg )
You can’t perform that action at this time.
0 commit comments