-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix invalid return type on unknown glyph #459
Fix invalid return type on unknown glyph #459
Conversation
Sorry, forgot to run cs fixer before pushing. Fixed! |
@k00ni Is the 'Needs work' tag still relevant or was it added because of the failing cs pipeline? What can I do to get this merged? |
It was because of failing CS pipeline and some code parts I wanted to discuss before using them. I am currently super busy and not sure when I work on this. At a first glance it looks good. @j0k3r can you take this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your pull request @PrinsFrank. If I understand you correctly your fix makes PDFParser more resistant against unknown glyphs as well as prevents TypeError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested it locally and it (indeed) fix the issue with the related PDF.
When an unknown glyph is encountered, the glyph itself is returned, which is a string:
The function 'translateChar' in Encoding.php directly returns the result of the above function, but has a return type of 'int'.
This PR returns null on an unknown glyph instead, and passes the $dec_av to the encoding function instead to preserve the glyph representation in the final result as in the test for issue #359
The Newly added test throws a TypeError about strings when the return type should be an int for unknown glyphs without these changes.