Skip to content

Commit

Permalink
Allow extra whitespace/newlines after stream tokens (Issue #40)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Oct 2, 2023
1 parent 6a4ce57 commit a83f7f5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DSONAME =
LDFLAGS =
LIBS = -lm -lz
RANLIB = ranlib
VERSION = 1.1.1
VERSION = 1.1.2
prefix = /usr/local


Expand Down
8 changes: 7 additions & 1 deletion pdfio-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
}

ptr += 3;
while (*ptr && isspace(*ptr & 255))
ptr ++;

_pdfioFileConsume(obj->pdf, (size_t)(ptr - line));

// Then grab the object value...
Expand All @@ -438,11 +441,14 @@ _pdfioObjLoad(pdfio_obj_t *obj) // I - Object
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);

if (!strcmp(line, "stream"))
{
// Yes, save its location...
// Yes, this is an embedded stream so save its location...
obj->stream_offset = _pdfioFileTell(obj->pdf);
PDFIO_DEBUG("_pdfioObjLoad: stream_offset=%lu.\n", (unsigned long)obj->stream_offset);
}
Expand Down

0 comments on commit a83f7f5

Please sign in to comment.