Allow extra whitespace/newlines after stream tokens (Issue #40)

This commit is contained in:
Michael R Sweet 2023-10-02 05:06:33 -04:00
parent 6a4ce57d09
commit a83f7f50ff
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244
3 changed files with 15 additions and 2 deletions

View File

@ -2,6 +2,13 @@ Changes in PDFio
================ ================
v1.1.2 (TBD)
------------
- Fixed an issue with broken PDF files containing extra CR and/or LF separators
after the object stream token (Issue #40)
v1.1.1 (March 20, 2023) v1.1.1 (March 20, 2023)
----------------------- -----------------------

View File

@ -29,7 +29,7 @@ DSONAME =
LDFLAGS = LDFLAGS =
LIBS = -lm -lz LIBS = -lm -lz
RANLIB = ranlib RANLIB = ranlib
VERSION = 1.1.1 VERSION = 1.1.2
prefix = /usr/local prefix = /usr/local

View File

@ -420,6 +420,9 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
} }
ptr += 3; ptr += 3;
while (*ptr && isspace(*ptr & 255))
ptr ++;
_pdfioFileConsume(obj->pdf, (size_t)(ptr - line)); _pdfioFileConsume(obj->pdf, (size_t)(ptr - line));
// Then grab the object value... // Then grab the object value...
@ -438,11 +441,14 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
return (false); return (false);
} }
if (tb.bufptr && tb.bufptr < tb.bufend && (*(tb.bufptr) == 0x0d || *(tb.bufptr) == 0x0a))
tb.bufptr ++; // Skip trailing CR or LF after token
_pdfioTokenFlush(&tb); _pdfioTokenFlush(&tb);
if (!strcmp(line, "stream")) if (!strcmp(line, "stream"))
{ {
// Yes, save its location... // Yes, this is an embedded stream so save its location...
obj->stream_offset = _pdfioFileTell(obj->pdf); obj->stream_offset = _pdfioFileTell(obj->pdf);
PDFIO_DEBUG("_pdfioObjLoad: stream_offset=%lu.\n", (unsigned long)obj->stream_offset); PDFIO_DEBUG("_pdfioObjLoad: stream_offset=%lu.\n", (unsigned long)obj->stream_offset);
} }