Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for binary content in formatContent() before a problematic rege…
…xp (#676) * Move formatContent check for binary content Some PDF files manage to serve binary content (a font, or an image, etc.) to the formatContent() method which only accepts text document streams. Since (strings) in PDF document streams can contain binary content (that gets decoded by a font library, for instance) we must test the document stream for text-only content EXCLUDING (string) content. Previously the check for text-only content was done *after* a regexp removing the (string)s from the stream, recursively extending the regexp to check for balanced parentheses. However for a sufficiently long binary stream, this might create a regexp long enough to cause a PHP error. The solution is to move the check for binary content *before* this (string)-removing regexp. Simplify the binary check by truncating the document stream at the first open parenthesis, which indicates the start of a (string), then testing what remains for valid UTF-8. This makes the later check for binary content unnecessary and it has been removed. Future work on this issue should be done to determine why PdfParser is creating PDFObject objects from binary data in the first place. * Update PDFObject.php Avoid using a throwaway variable. * Update PDFObject.php Don't update this indentation. * Update src/Smalot/PdfParser/PDFObject.php Use strict false check. Co-authored-by: Konrad Abicht <[email protected]> --------- Co-authored-by: Konrad Abicht <[email protected]>
- Loading branch information