DEV Community

王磊
王磊

Posted on

An ANSI PST B-Tree Walk Used Greater-Than on Two Long Objects. That Compared Their Decimal Strings.

Mailward's email archive format guide describes a PST as a single-file database: a node database built from B-trees holding blocks, with a property layer on top. I fetched the live HTML today. I did not open a PST.

The same page says the format exists in two incompatible variants. The ANSI variant, written by Outlook 97 through 2002, tops out at 2 GB. The Unicode variant arrived with Outlook 2003 and is what essentially every modern .pst uses. A reader that only handles one, it says, will fail confusingly on the other. I did not compare a reader that handles only one variant, so that failure mode stays as the page's wording.

The page that opens a PST without Outlook treats ANSI as best-effort. Its FAQ for an old file from Outlook 2002 or earlier says Mailward recognizes an ANSI header and hands it to the same reader, and that a file it cannot parse is reported as an ANSI-era PST that could not be read, not as a generic failure. I have not submitted an unreadable ANSI file, so I am repeating the published wording, not a run I observed.

The walk itself still has to choose which child to descend when a B-tree page is a branch, not a leaf. The JavaScript library I use for these files, pst-extractor, made that choice with > on two Long objects. In JavaScript, that comparison is lexicographic once the values are strings. I checked the expression myself: "2082" > "97" is false. A numeric comparison of the same identifiers would have gone the other way. When the keys were compared as their decimal strings, a lookup on an ANSI file whose node or block B-tree had a branch level could go down the wrong child, miss the id in the leaf, and fail. I did not open such a file for this article, and I am not reporting a failure I reproduced today.

Mailward's ANSI walk now compares those keys numerically. Unicode files still use the library's own walk. I did not re-open a Unicode PST to compare the two paths.

The site's llms.txt states the same split in one line: two incompatible variants, ANSI (Outlook 97-2002, 2 GB ceiling) and Unicode (Outlook 2003+). It does not describe the branch comparison. I am not collapsing that summary with the walk above into one observed open.

Disclosure: I built it. Mailward is my project, not a Microsoft or Outlook product. The format-guide wording, the best-effort FAQ, and the llms.txt variant split above are Mailward's published text. The string comparison "2082" > "97" is a JavaScript expression I checked. I have not opened an ANSI PST myself for this article.

Top comments (0)