Implement ArrayOfPropertyValues + fix nested PropertySet, unknown FileNode, and TextExtendedAscii decode#33
Open
Thenewmanator15 wants to merge 1 commit into
Conversation
…eNode, and text decode Four fixes that let real OneNote (.one) sections parse end-to-end instead of crashing: 1. PropertySet type 0x10 (ArrayOfPropertyValues) was `raise NotImplementedError`. Implemented per [MS-ONESTORE] 2.6.9: a uint32 count, then (only when count>0) one prototype PropertyID, then `count` PropertySet structures. 2. PropertySet type 0x11 (nested PropertySet) called `PropertySet(file)` with the wrong arg count and would raise TypeError as soon as it was reached. It now passes the parent OID/OSID/ContextID streams and document, like every other site. 3. FileNode: an unrecognised FileNodeID fell through to `else: p = 1` without setting `self.data`, then the `baseType == 2` branch dereferenced `self.data.ref` -> AttributeError. Set `self.data = None` and guard the child-list recursion on a present `.ref`. 4. get_properties decoded the single-byte TextExtendedAscii property as UTF-16, turning ASCII text into CJK and (on odd lengths) falling back to raw hex. Decode TextExtendedAscii as cp1252 and the Unicode text as utf-16-le. With these, a 60-page notebook parses fully (15477 property nodes, embedded files recovered) and text comes out readable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Four fixes that let real OneNote
.onesections parse end-to-end instead of crashing partway throughPropertySet/FileNodeparsing.1.
PropertySettype0x10(ArrayOfPropertyValues) — wasNotImplementedErrorThe hard blocker. Implemented per [MS-ONESTORE] §2.6.9: a
uint32count, then (only when count > 0) one prototypePropertyID, thencountPropertySetstructures, drawing ObjectIDs from the parent's OID/OSID/ContextID streams.2.
PropertySettype0x11(nested PropertySet) — wrong arg countself.rgData.append(PropertySet(file))would raiseTypeErrorthe moment a nested property set was reached (__init__needsfile, OIDs, OSIDs, ContextIDs, document). Now passes the parent streams like every other call site.3.
FileNode: unrecognised FileNodeID →AttributeErrorAn unknown
FileNodeIDfell through toelse: p = 1without settingself.data, then thebaseType == 2branch dereferencedself.data.ref. Now setsself.data = Noneand guards the child-list recursion on a present.ref.4.
get_properties:TextExtendedAsciimis-decodedThe single-byte
TextExtendedAsciiproperty was decoded as UTF-16, turning ASCII into CJK (e.g.Hypothesis→祈潰桴獥獩) and, on odd byte lengths, silently falling back to raw hex. Now decodesTextExtendedAsciiascp1252and the Unicode text property asutf-16-le.Impact
On a real 60-page notebook this goes from an early crash to a full parse — 15,477 property nodes, all pages, embedded files recovered, and readable text. Fixes 1–3 are structural (parse completes); fix 4 makes the extracted text usable.
Notes
Changes are confined to
pyOneNote/FileNode.py. TheArrayOfPropertyValueslayout follows the count-then-prototype-then-N-PropertySets structure in [MS-ONESTORE] §2.6.9; verified against a notebook whose node-type histogram (thousands ofObjectDeclaration2RefCountFND, correct page/title/table/list counts) confirms correct stream alignment.