summaryrefslogtreecommitdiff
path: root/source/pdf
AgeCommit message (Collapse)Author
2018-08-22Remove the old 'nested depth' tracking.Tor Andersson
This was used to prevent infinite cycles in the Type3 font CharProcs, but the previous commits forbids all cycles in order to prevent memory leaks due to cyclic reference counts.
2018-08-22Bug 699666: Forbid cycles in Type3 font CharProcs.Tor Andersson
Thanks to oss-fuzz for reporting.
2018-08-22Bug 699653: Avoid dropping filter chain once too often in case of error.Sebastian Rasmussen
build_filter_chain_drop() promises to extend (according to the fs argument) the filter chain it is given, or in case of exception throw away the at that point potentially extended filter chain it was given from the beginning. Because build_filter_chain_drop() calls build_filter_drop() for every filter it adds it doesn't need to do any cleanup of the filter chain on its own, that's build_filter_drop()'s responsibility. Prior to this commit fz_catch() in build_filter_chain_drop() which would drop the filter chain one time too many (it was already dropped by build_filter_drop()), causing the callers to use a stale pointer. Now once the extra fz_drop_stream() has been removed the logic works as it ought to, even in the case of exceptions. Thanks to oss-fuzz for reporting.
2018-08-21Bug 699652: Fix postscript value stack underflow for index operator.Sebastian Rasmussen
Thanks to oss-fuzz for reporting.
2018-08-21Bug 699271: Fix eternal loop when skipping space before EOF.Sebastian Rasmussen
Thanks to Michael J Gruber for providing this oneliner.
2018-08-21Fix form recalculation issue.Tor Andersson
Commit f533104 accidentally removed the line that updated the value variable. Also set the field value to a name object for check boxes and radio buttons, as per the specification.
2018-08-21Handle form fields where the V is a name object.Tor Andersson
2018-08-21Improve parameter names.Tor Andersson
2018-08-21Fix 699625: Apply more vertical padding for multiline form fields.Tor Andersson
The exact value used by Adobe will need further investigation, but this gets pretty close.
2018-08-21Fix 699641: Follow Parent chain when looking up DA in annotations.Tor Andersson
The DA property is marked as inheritable for text fields. It is not marked inheritable for FreeText annotations, but I don't believe it will be a problem to treat it as such anyway.
2018-08-21Avoid unnecessary NULLing of doc->focusPaul Gardiner
doc->focus refers to a widget record within a specific page. We shouldn't NULL it when dropping a different page.
2018-08-21Choose the lastmost annotation rather than firstmost as mouse event target.Paul Gardiner
pdf_pass_event iterates through the annotations to find one with a bounding box that encompasses the event point. We were choosing the first found, whereas later annotations are considered above earlier ones so we should be choosing the last found.
2018-08-20Use "PDF Alert" as the default javascript alert title.Paul Gardiner
Without this, for alerts where no title is specified, "undefined" was displayed.
2018-08-20Fix inability to uncheck check boxes.Paul Gardiner
Just a case of fixing some incorrect logic.
2018-08-10Check that characters aren't left over in AFSpecial_KeystrokeEx.Fred Ross-Perry
In the Javascript function AFSpecial_KeystrokeEx, if there are characters left over after exhausting the format string, it's not a match.
2018-08-10Don't trigger the keystroke event when clearing a form field.Tor Andersson
This fixes part of bug #699577. The keystroke event was preventing form fields being cleared, which is presumably not intended behaviour.
2018-08-10Treat invalid and truncated hex string characters as '0'.Tor Andersson
2018-08-10Use proper name space for form field flag constants.Tor Andersson
2018-08-10Get and set PDF form field names as text strings.Fred Ross-Perry
2018-08-10Remove functions that implement duplicate functionality.Tor Andersson
pdf_get_inheritable also looks in trailer/Root/AcroForm for missing keys, but this behavior is not supported by anything in the specification.
2018-08-10Detect cycles in pdf_dict_get_inheritable.Tor Andersson
Remove duplicate function pdf_lookup_inherited_page_item.
2018-08-10Respect NoRotate flag for icon-based annotations.Tor Andersson
2018-08-10Clean up null/range/endstream filter.Tor Andersson
Use separate functions to keep the code simpler. Use memmem to simplify and optimize search for 'endstream' token. Do not look for 'endobj' since that could cause a false positives in compressed object streams that have duff lengths.
2018-08-10Rejig pdf_update_page and pdf_update_annot.Tor Andersson
The intent is for a user to iterate over the annotations on a page calling pdf_update_annot for each one. If this function returns true, then the annotation has changed since the last time it was called, and the user needs to re-render. pdf_update_page is a simple loop over the annotations on a page, for use if you only care about page level granularity. Users should no longer look at or change the pdf_annot.has_new_ap field.
2018-08-10Bug 699629: Avoid referencing stale/moved nodes in CMap splay tree.Sebastian Rasmussen
Thanks to oss-fuzz for reporting.
2018-08-10Bug 699628: Add fz_var to variable set in fz_try and used in fz_always.Sebastian Rasmussen
When pdf_xobject_transparency() indicates transparency, pdf_run_xobject() will push a mask with 2 components (gray + alpha). Because fz_var was missing for the transparency variable its value would, if fz_throw() was called, not be preserved in fz_always{}. This means that fz_always{} would never pop the mask from the stack. At a later stage some code would call fz_end_mask() and then trigger an assert() where the number of components was restricted to 1. Marking the variable with fz_var means that the mask will now be popped as expected. Thanks to oss-fuzz for reporting.
2018-08-10Coverity found a missing break, add it.Sebastian Rasmussen
The intent with the previous code was to default to black upon unsupported number of components in the color array. The code however first set all components to zero then to the value of the first component of the color array. Now the code follows the original intent.
2018-08-10Bug 699627: Ignore CMap input ranges outside of input codespaces.Sebastian Rasmussen
Thanks to oss-fuzz for reporting.
2018-08-10Implement check for range overlap between cmap splay tree nodes.Sebastian Rasmussen
2018-08-10Bug 699626: Avoid trying to populate OCG ui struct without entries.Sebastian Rasmussen
Thanks to oss-fuzz for reporting.
2018-07-17Disallow incremental updating for documents that have hybrid xrefsPaul Gardiner
Alter pdf_can_be_saved_incrementally to return false when a hybrid xref file has been opened. This doesn't enforce the behaviour, but will ensure it for apps that determine their behaviour via this test function. Once changes have been saved to such a file, it is no longer hybrid and so further saving steps can use incremental updates. This change was made because we were previously unable to sign hybrid xref documents in a way that was satisfactory to Adobe Reader. Adobe Reader reorganises hybrid xref files, thus invalidating any signature.
2018-07-17Fix memory leaks in document signing functionsPaul Gardiner
2018-07-17Fix memory leak in form recalculation functionPaul Gardiner
2018-07-06Bug 699308: Fix stream reading logic to better cope with duff Lengths.Robin Watts
Always look for the "endstream" marker after a PDF stream to see if we've hit the end. Allow for "endobj" to cope with producers that omit endstream entirely. Avoid slowing down legal files by only checking for the end marker after the specified length has been read.
2018-07-06Add debug functionality to show lexed stream contents.Robin Watts
If you define DUMP_LEXER_STREAM than the lexer dumps the input that it reads from the stream.
2018-07-06Squash spurious warnings with CIDToGIDMap.Robin Watts
A missing CIDToGIDMap is treated as identity.
2018-07-06Fix stray consts.Robin Watts
2018-07-06Add pdf_dict_get_rect and pdf_dict_get_matrix helpers.Tor Andersson
2018-07-05Fix document signing adding unnecessary incremental updatesPaul Gardiner
When a document is signed multiple times, an incremental update is needed for each, the multiple updates sometimes written to the file as a single saving operation. Within pdf_sign_signature it is the call to pdf_signature_set_value that marks the current section of the xref to which changes are recorded as "full", so that subsequent changes will trigger the creation of a new section. Within pdf_sign_signature we were creating the signature's appearance stream after the call to pdf_signature_set_value and hence triggering an extra unnecessary setction. This commit moves the pdf_signature_set_value to after the creation of the appearance stream, so that we need only as many new xref sections as there are signings.
2018-07-05Add digital signature appearance synthesis.Tor Andersson
The pdf_update_signature_appearance function must be called directly by the signing code when it signs the document; as only the signing code has all the text that needs to be written into the appearance.
2018-07-05Purge unused functions.Tor Andersson
2018-07-05Pass rects by value: device and document interface.Tor Andersson
2018-07-05Pass matrices by value: device and document interface.Tor Andersson
2018-07-05Pass rect and matrix by value in geometry functions.Tor Andersson
Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain.
2018-07-05Add stack traces to JS error messages.Tor Andersson
2018-07-05Fix bug in util.js: padZeros is a local function.Tor Andersson
2018-07-05Return true if any annots have new APs in pdf_update_page.Tor Andersson
2018-07-05Use separate X and Y text padding in text appearance streams.Tor Andersson
2018-07-05Use real WinAnsi encoding when writing appearance stream text.Tor Andersson
2018-07-05Support background and border color in Widget/Tx and Widget/Ch.Tor Andersson