Skip to content
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

Update oleform to fix a padding bug and add an enhancement #775

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nvdp01
Copy link

@nvdp01 nvdp01 commented Jun 29, 2022

This PR includes one bug fix and one enhancement addition.

  1. The properties of type String are stored in OLE form stream with a padding of multiples of four bytes as mentioned in MS-OFORMS section 2.1.1.2.4 - Padding and Alignment. Various properties which are of type String (specifically fmString) such as Name, ControlTipText, Caption etc. were being read in oleform without accounting for this padding. This often lead to prepending of 1-3 to junk bytes at the start of extracted value (and discarded an equal number of valid bytes at the end of value). 1b2cf45 fixes this bug by using stream.will_pad() whenever a String value is read.

  2. Controls having ClsidCacheIndex = 14, called Frame control, can have child controls embedded in them while the control itself is embedded in a parent control. In such cases, an i n child stream exists within the parent stream directory - n being the ID of the Frame control. This is described in section 2.1.2.2.2 - Embedded Parents. This i stream may contain certain properties such as Caption of the Frame Control. fd0f0c5 adds a function consume_EmbeddedFormControl() to extract Caption property in such cases for Frame controls. This commit also relies on bc7c53f which fixes a minor bug in FormPropMask _names list.

More information and context around these changes can be found in my blog post.

Account for padding of String values as described in MS-OFORMS Section 2.1.1.2.4
Updated FormPropMask _names list to remove duplicated 'fBooleanProperties' and add missing 'fBorderStyle'
Add a function consume_EmbeddedFormControl() which extracts and returns caption value from an i sub-stream for Frame controls (having ClsidCacheIndex = 14)
Update consume_CommandButtonControl() to extract Caption value
@nvdp01
Copy link
Author

nvdp01 commented Jul 16, 2022

Added a commit cddce22 which updates the function consume_CommandButtonControl() to extract Caption property of CommandButton controls (MS-OFORMS 2.2.1 - CommandButton Control Structure). The changes are essentially the same as what commits d31c4d9 and a2d9bc6 did for consume_LabelControl() function.

This addition was required for extracting Caption value of a CommandButton in this maldoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants