Merge pull request #6897 from radarhere/eps

Stop reading when EPS line becomes too long
This commit is contained in:
Hugo van Kemenade 2023-01-18 09:57:31 +02:00 committed by GitHub
commit 876b9f4ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,11 +173,13 @@ class PSFile:
self.fp.seek(offset, whence)
def readline(self):
s = [self.char or b""]
self.char = None
s = []
if self.char:
s.append(self.char)
self.char = None
c = self.fp.read(1)
while (c not in b"\r\n") and len(c):
while (c not in b"\r\n") and len(c) and len(b"".join(s).strip(b"\r\n")) <= 255:
s.append(c)
c = self.fp.read(1)