ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
295 stars 72 forks source link

Tweak the writing of offsets when writing user defined properties #106

Closed Numpsy closed 4 months ago

Numpsy commented 4 months ago

As per the Microsoft documentation at https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-oshared/fe59ffd9-79e9-44fb-a1c9-2466057b05c6 -

The total size of this property set’s PropertySet structure ([MS-OLEPS] section [2.20](https://learn.microsoft.com/en-us/openspecs/windows_protocols/MS-OLEPS/aefcbddf-f299-4f5e-a9da-65ce4ca55075)) MUST be padded to a multiple of 4 bytes

but the padding code was commented out? When debugging an attempt at writing the user defined properties, I had a case where the size ended up at 299 bytes when it should really be padded up to 300, and I think this fixes that.

@@NOTE@@ It might need additional padding adding to the end of the user defined section, but the documents I'm testing with are all ending up with the size a multiple of 4 with no padding, so I don't yet have a test for that case.

ironfede commented 4 months ago

@Numpsy , do you have a test case to add as a unit test for this PR? Thanks!

Numpsy commented 4 months ago

I've been working with a few unit tests locally, but it was a bit hard to do them for each PR because you need both this one and the dictionary ones to write all the required data. I'll get everything synched up, and try to add tests for all the cases.

Thanks for merging the changes :-)