-
Notifications
You must be signed in to change notification settings - Fork 335
Minor fixes and cleanup #1
base: master
Are you sure you want to change the base?
Conversation
Generated by stringer.
Encountered parsing NYT crosswords.
Restoring from an empty graphics stack looks like a mistake in the PDF, but other PDF readers handle it fine, and ignoring it appears to work correctly. Encountered parsing NYT crosswords.
Some PDFs contain non-whitespace junk after the %%EOF marker. Other PDF parsers handle it fine. Encountered parsing NYT crosswords.
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.
And at the end, please squash the commits into one :)
} | ||
return c | ||
default: | ||
panic("bad content kind") |
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 think this panic here might cause undocumented and unexpected problems for users. I was using the package earlier on the bus back from school and wrote code that invoked p.Content() without explicitly checking the Kind(). Perhaps we can just make an explicit check for Array then let the contentForStream handle be the catch all?
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.
Are there other known cases? Would contentForStream handle them correctly?
It's been ages since I've looked at this code.
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.
Good question @josharian: I am not sure, I am not well versed with the PDF spec but I thought it was a little unexpected to panic on other types. So far I've only seen mentions of Stream and Array for "Content" in the spec.
Perhaps: I think it would handle the "other cases" properly because it contains the almost the same code before this patch, and that has worked in the past.
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.
Or it was silently returning junk before this patch. I'd rather be explicit, all else being equal.
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.
Gotcha, yap that makes sense to me now.
No description provided.