Skip to content

Conversation

@tyler-sommer
Copy link
Contributor

We ran into an issue where taking a human-crafted word doc and modifying it with godocx would then lead to godocx not being able to parse the document, citing:

failed to open document: invalid OnOff string

I tracked this back to the TitlePG field on ctypes.SectionProp. Prior to modification by godocx, this was encoded as:

<w:titlePg/>

After modification with godocx, this would be encoded as:

<w:titlePg w:val=""></w:titlePg>

The empty string in Val would cause decoding to fail.

This PR fixes the issue, however, I am not sure this is the fully correct way to go.

Many *OnOff fields are just that (pointer to OnOff), but TitlePG is *GenSingleStrVal[stypes.OnOff] and GenSingleStrVal encodes regardless of whether the value it stores is empty. Rather than modifying GenSingleStrVal, which would probably break things, I opted to just not encode TitlePG when it is empty. Let me know if there's a better way to handle this.

Thanks!

@tyler-sommer
Copy link
Contributor Author

After some more testing, this does not work as expected (completely breaks page title rendering, it seems). I'll dig into this some more. In the meantime, would love any suggestions :)

Thanks again!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant