<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: 王磊</title>
    <description>The latest articles on DEV Community by 王磊 (@_172c9b2760d6c5bc1e8966).</description>
    <link>https://dev.to/_172c9b2760d6c5bc1e8966</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3964002%2Fd67ecd17-1334-49df-abff-4386876a8a76.png</url>
      <title>DEV Community: 王磊</title>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/_172c9b2760d6c5bc1e8966"/>
    <language>en</language>
    <item>
      <title>How Waveward Handles a Truncated Audacity .aup Document</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Sun, 15 Nov 2026 02:09:55 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/how-waveward-handles-a-truncated-audacity-aup-document-1afd</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/how-waveward-handles-a-truncated-audacity-aup-document-1afd</guid>
      <description>&lt;p&gt;Audacity 1.x and 2.x projects are an XML document (&lt;code&gt;.aup&lt;/code&gt;) plus a &lt;code&gt;_data&lt;/code&gt; folder of audio block files. The &lt;code&gt;.aup&lt;/code&gt; stores project structure and references to those blocks; it does not contain the audio samples. I wrote a parser for that document in Waveward. If the file ended inside a tag, or with elements still open, Waveward used to refuse the open as unreadable.&lt;/p&gt;

&lt;p&gt;That refusal throws away a prefix that may still be usable, but opening the file is not the same as getting the whole project back. Waveward now keeps the complete entries it can still parse, and only the audio those entries still name in the &lt;code&gt;_data&lt;/code&gt; folder. A cut that falls before any usable entry, a block the document never finished naming, or a block file that is missing is not recovered; missing blocks play as silence and are counted. The &lt;a href="https://aup4.aivismonitor.com/aup-to-mp3" rel="noopener noreferrer"&gt;AUP to MP3&lt;/a&gt; page puts this as "usually not all of it," and says a file that stops part-way opens up to its last complete entry, with a note of what is missing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two save paths, and why they are not the same
&lt;/h2&gt;

&lt;p&gt;I read Audacity's save code at the public tags the page cites. I did not run Audacity to watch a save fail.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://github.com/audacity/audacity/blob/Audacity-2.1.3/src/Project.cpp#L3707-L3717" rel="noopener noreferrer"&gt;Audacity 2.1.3's &lt;code&gt;Project.cpp&lt;/code&gt;&lt;/a&gt;, if the project file already exists it is renamed to a safety name — the file name plus &lt;code&gt;.bak&lt;/code&gt;, or plus &lt;code&gt;~&lt;/code&gt; under GTK — and the new document is then opened under the real name (&lt;code&gt;saveFile.Open(mFileName, "wb")&lt;/code&gt;, around line 3797). That is a write in place. The backup is removed only after the write succeeds (line 3873). If writing throws, the incomplete file is deleted and the backup is renamed back (lines 3814–3818). The AUP to MP3 page also attributes this pattern to 1.3.14 and 2.0.6; I did not read those two tags myself. From that in-place open, a crash or power cut &lt;em&gt;during the write itself&lt;/em&gt; — a path the caught-exception rollback does not cover — can leave a new &lt;code&gt;.aup&lt;/code&gt; that stops part-way, with the previous save beside it as &lt;code&gt;.aup.bak&lt;/code&gt; (or &lt;code&gt;.aup~&lt;/code&gt; on Linux). That is an inference from the write path, not a failure I reproduced.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/audacity/audacity/blob/Audacity-2.4.2/src/ProjectFileManager.cpp#L402-L415" rel="noopener noreferrer"&gt;Audacity 2.4.2's &lt;code&gt;ProjectFileManager.cpp&lt;/code&gt;&lt;/a&gt; still does the &lt;code&gt;.bak&lt;/code&gt; / &lt;code&gt;~&lt;/code&gt; rename, but writes the document through &lt;code&gt;XMLFileWriter&lt;/code&gt;, described there as a temporary file renamed into place. Because the live &lt;code&gt;.aup&lt;/code&gt; is not overwritten in the same way, that 2.4.2 path should not be taken as leaving a half-written &lt;code&gt;.aup&lt;/code&gt;. An unfinished save can still leave the &lt;code&gt;.bak&lt;/code&gt; beside the project: 2.4.2 removes that copy only after a successful save, and a failure that it handles is written to put the copy back. The same file also refuses to open a path ending in &lt;code&gt;.aup.bak&lt;/code&gt;, with the warning "You are trying to open an automatically created backup file."&lt;/p&gt;

&lt;p&gt;An interrupted copy or download is a different failure: the file can end early, or turn into zero bytes, without any &lt;code&gt;.bak&lt;/code&gt; from a save. I have not watched that happen either; it is a cause the page names, not a case I ran.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Waveward keeps, and what it still refuses
&lt;/h2&gt;

&lt;p&gt;When the document ends early, Waveward opens it from the complete prefix and reports that the file stops part-way. That report also mentions a copy named &lt;code&gt;song.aup.bak&lt;/code&gt; (or &lt;code&gt;song.aup~&lt;/code&gt; on Linux) next to it as the likely previous save. Waveward accepts &lt;code&gt;.aup.bak&lt;/code&gt; and &lt;code&gt;.aup~&lt;/code&gt; as project documents, after the &lt;code&gt;.aup&lt;/code&gt; itself, and reads them only. The audio still has to come from the &lt;code&gt;_data&lt;/code&gt; folder; a later edit may already have removed some of those blocks, and those play as silence.&lt;/p&gt;

&lt;p&gt;The project's tests require a document that ends early to open from its complete prefix, a half-written &lt;code&gt;&amp;lt;waveblock&amp;gt;&lt;/code&gt; to be dropped rather than kept as empty audio, a complete document with zeros appended not to be treated as damaged, and a mismatched end tag in the middle still to be refused. I did not run those tests, and I did not reopen the files myself.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://aup4.aivismonitor.com/recover-audacity-project" rel="noopener noreferrer"&gt;recovery page&lt;/a&gt; says the same for an old &lt;code&gt;.aup&lt;/code&gt;: if it stops part-way, it opens up to its last complete entry, and the &lt;code&gt;.aup.bak&lt;/code&gt; opens there too. Integrity check, rebuild, and earlier database saves on that page still apply only to &lt;code&gt;.aup3&lt;/code&gt; and &lt;code&gt;.aup4&lt;/code&gt;. People who land on the &lt;a href="https://aup4.aivismonitor.com/aup3-to-mp3" rel="noopener noreferrer"&gt;AUP3 to MP3&lt;/a&gt; converter with an Audacity 2 &lt;code&gt;.aup&lt;/code&gt; are sent to the AUP to MP3 page: that converter treats the old format as a different kind of project, a small XML file plus its &lt;code&gt;_data&lt;/code&gt; folder, which Audacity 4 cannot import.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Waveward can use a truncated &lt;code&gt;.aup&lt;/code&gt; up to its last complete entry. It cannot promise the rest of the project, or any audio the remaining entries do not still name.&lt;/li&gt;
&lt;li&gt;The Audacity 2.1.3 save path I read writes the new document in place after renaming the previous save to &lt;code&gt;.aup.bak&lt;/code&gt; (or &lt;code&gt;.aup~&lt;/code&gt;). Audacity 2.4.2 keeps the rename but commits through a temporary file, so the same partial overwrite should not be assumed.&lt;/li&gt;
&lt;li&gt;Audacity 2.4.2 will not open &lt;code&gt;.aup.bak&lt;/code&gt;. Waveward will, together with the &lt;code&gt;_data&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;A document that ends early is a different failure from one that is wrong in the middle. A mismatched tag should still be refused.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Disclosure: I built it. Waveward is my project; the save-and-backup steps quoted above are from Audacity 2.1.3 and 2.4.2, not from code I wrote.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>xml</category>
      <category>audio</category>
    </item>
    <item>
      <title>I Wrote That XstReader Had No Mac Build. That Was Only True of the Viewer.</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Sat, 14 Nov 2026 03:22:46 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/i-wrote-that-xstreader-had-no-mac-build-that-was-only-true-of-the-viewer-33in</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/i-wrote-that-xstreader-had-no-mac-build-that-was-only-true-of-the-viewer-33in</guid>
      <description>&lt;p&gt;I maintain a comparison page about &lt;a href="https://pst.aivismonitor.com/xstreader-alternative" rel="noopener noreferrer"&gt;XstReader&lt;/a&gt;, an open-source desktop viewer for Outlook &lt;code&gt;.pst&lt;/code&gt; and &lt;code&gt;.ost&lt;/code&gt; files. For a while the page treated the whole project as Windows-only. One fact line read "Windows desktop only — no macOS or Linux build." The body said there was no macOS build and no Linux build.&lt;/p&gt;

&lt;p&gt;That wording is true of the viewer. It is not true of the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the project's README actually says
&lt;/h2&gt;

&lt;p&gt;I opened the README at &lt;a href="https://github.com/Dijji/XstReader" rel="noopener noreferrer"&gt;github.com/Dijji/XstReader&lt;/a&gt; while writing this. Two products live in the same tree:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;XstReader&lt;/strong&gt;, the three-pane viewer, "requiring only .Net Framework 4, and with no dependency on any Microsoft Office components."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;XstPortableExport&lt;/strong&gt;, "a portable version based on .Net Core 2.1 that can be run on Windows, Mac, Linux etc."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The portable tool is a command-line exporter, not a second viewer. The same README is explicit about what that portability costs:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;in order to remain portable, two areas of functionality have to be #ifdef'd out in order not to create a framework dependency and so tie the program to Windows. These are support for RTF body formats, and support for MIME decryption.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A Windows command-line exporter, XstExport, is listed as well. The cross-platform binary is XstPortableExport.&lt;/p&gt;

&lt;p&gt;I also fetched the GitHub Releases API for the repository today. The latest release is still tagged &lt;strong&gt;v1.14&lt;/strong&gt;, published 2 January 2021, 18:27 UTC. I did not install or run either exporter.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the page says now
&lt;/h2&gt;

&lt;p&gt;The comparison row and the fact list now limit "Windows only" to the viewer, and name XstPortableExport as a command-line exporter that the README says also runs on Mac and Linux. A fact line records the latest release as v1.14, 2 January 2021. A new FAQ, "Is there an XstReader for Mac?", states the same split: no viewer for Mac; a portable exporter that writes messages out as &lt;code&gt;.html&lt;/code&gt;, &lt;code&gt;.rtf&lt;/code&gt; or &lt;code&gt;.txt&lt;/code&gt; with attachments in folders, without RTF body support or MIME decryption in that build, and with no window for reading.&lt;/p&gt;

&lt;p&gt;The corrected direct answer still points at two ways to &lt;em&gt;read&lt;/em&gt; mail on a Mac: a terminal conversion with &lt;a href="https://pst.aivismonitor.com/readpst-alternative" rel="noopener noreferrer"&gt;readpst&lt;/a&gt;, or opening the file in the browser. XstPortableExport is an export path, not a replacement for those.&lt;/p&gt;

&lt;p&gt;A test file, &lt;code&gt;tests/xstreader-claims.test.ts&lt;/code&gt;, forbids the old "no macOS or Linux build" sentences, requires the page to name XstPortableExport, .NET Framework 4, and v1.14, and checks that the new FAQ mentions the two omitted features. I read that test. I did not run the suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A repository can ship more than one program. A single "Runs on" cell that describes only the GUI will misstate the project.&lt;/li&gt;
&lt;li&gt;Read the project's own README before repeating a platform line. The portable exporter and the two &lt;code&gt;#ifdef&lt;/code&gt;'d features were documented there.&lt;/li&gt;
&lt;li&gt;"It runs on a Mac" is still the wrong sentence if the Mac build cannot show a mailbox. Say that it exports files, and say what it leaves out.&lt;/li&gt;
&lt;li&gt;Pin the distinction in a test that fails if the old, flatter wording comes back.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same project is listed in the PST row of the &lt;a href="https://pst.aivismonitor.com/email-archive-formats" rel="noopener noreferrer"&gt;email archive formats guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclosure: I built it.&lt;/strong&gt; Mailward, the site these pages are on, is my own project.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Source note (2026-11-14): I read Mailward commit 2076acf (AuthorDate 2026-11-12 11:11:32 +0800), the current XstReader page copy, and the new tests. I also opened the upstream README and fetched &lt;code&gt;https://api.github.com/repos/Dijji/XstReader/releases/latest&lt;/code&gt; (200, tag v1.14, published_at 2021-01-02T18:27:21Z). I did not run the test suite, and I did not run XstPortableExport myself.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>csharp</category>
      <category>email</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Google and Bing Never Crawled My Four HTML Pages Whose Paths Ended in pdf</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Fri, 13 Nov 2026 02:13:55 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/google-and-bing-never-crawled-my-four-html-pages-whose-paths-ended-in-pdf-1gcf</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/google-and-bing-never-crawled-my-four-html-pages-whose-paths-ended-in-pdf-1gcf</guid>
      <description>&lt;p&gt;I shipped four HTML pages that convert email archives to PDF. Their addresses were &lt;code&gt;/eml-to-pdf&lt;/code&gt;, &lt;code&gt;/msg-to-pdf&lt;/code&gt;, &lt;code&gt;/mbox-to-pdf&lt;/code&gt; and &lt;code&gt;/pst-to-pdf&lt;/code&gt;. They are ordinary Next.js pages. They return &lt;code&gt;text/html&lt;/code&gt;. They are not PDF files.&lt;/p&gt;

&lt;p&gt;Sixteen days after launch, according to the commit that moved them, Google still listed every one as "URL is unknown to Google". Bing, which had crawled the rest of the site and indexed 32 pages there, had held &lt;code&gt;/eml-to-pdf&lt;/code&gt; at "Discovered but not crawled" since the launch date. The same commit records that the responses, including for Googlebot and bingbot, matched pages those engines did crawl. I did not re-open Search Console or Bing Webmaster myself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one trait they shared
&lt;/h2&gt;

&lt;p&gt;Other pages on the site were being crawled in the usual way. These four were not. The thing they have in common — and that an earlier rename had kept — is a path that ends in &lt;code&gt;pdf&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On 2026-11-02, &lt;code&gt;/eml-to-pdf&lt;/code&gt; was moved to &lt;code&gt;/convert-eml-to-pdf&lt;/code&gt;, the &lt;code&gt;convert-&amp;lt;x&amp;gt;-to-&amp;lt;y&amp;gt;&lt;/code&gt; shape other crawled converters on the site already use. The content did not change. After three days the new address was still unknown to Google, like the three pages that had stayed put, so that move was undone. &lt;code&gt;/convert-eml-to-pdf&lt;/code&gt; also ends in &lt;code&gt;pdf&lt;/code&gt;. Changing the prefix was not enough.&lt;/p&gt;

&lt;p&gt;A crawler that looks at the last segment of a URL can treat &lt;code&gt;…/eml-to-pdf&lt;/code&gt; the way it treats &lt;code&gt;…/report.pdf&lt;/code&gt;: as a document to skip, or to fetch with an Accept header that does not expect HTML. That is a hypothesis, not a proof. When the four pages were renamed, there was no control left on purpose. This change cannot show that the ending was the cause. It only removes the shared trait.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the paths are now
&lt;/h2&gt;

&lt;p&gt;Each page now ends in &lt;code&gt;-converter&lt;/code&gt;. The old addresses, including the short-lived experiment URL, send a permanent redirect straight to the new one — no chain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/convert-eml-to-pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/eml-to-pdf-converter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;permanent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/eml-to-pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/eml-to-pdf-converter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;permanent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/msg-to-pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/msg-to-pdf-converter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;permanent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/mbox-to-pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/mbox-to-pdf-converter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;permanent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/pst-to-pdf"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/pst-to-pdf-converter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;permanent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I confirmed the live responses myself: &lt;code&gt;/eml-to-pdf-converter&lt;/code&gt; returns 200 with &lt;code&gt;content-type: text/html; charset=utf-8&lt;/code&gt;. &lt;code&gt;/eml-to-pdf&lt;/code&gt; and &lt;code&gt;/convert-eml-to-pdf&lt;/code&gt; both return 308 to &lt;code&gt;/eml-to-pdf-converter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A test in &lt;code&gt;tests/tool-pages.test.ts&lt;/code&gt; pins those five redirects, requires each &lt;code&gt;/&amp;lt;format&amp;gt;-to-pdf-converter&lt;/code&gt; path to be in the page registry, requires that no registered path matches &lt;code&gt;/pdf$/i&lt;/code&gt;, and requires that no redirect's destination is another redirect's source. I read that test. I did not run the suite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An HTML page can still look like a PDF file if its path ends in &lt;code&gt;pdf&lt;/code&gt;. The &lt;code&gt;Content-Type&lt;/code&gt; you send does not help if the crawler never requests the URL.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/convert-eml-to-pdf&lt;/code&gt; has the same problem as &lt;code&gt;/eml-to-pdf&lt;/code&gt;. If the ending is the cause, the last token is what matters, not the words in front of it.&lt;/li&gt;
&lt;li&gt;If you move a URL, point every old address at the current one in a single hop. A 308 to an address that 308s again is a chain you will have to explain later.&lt;/li&gt;
&lt;li&gt;Pin the rule, not just today's slugs: no registered path ends in &lt;code&gt;pdf&lt;/code&gt;, and no redirect lands on another redirect.&lt;/li&gt;
&lt;li&gt;Treat the "crawlers took it for a file" reading as a hypothesis until a later crawl shows the new addresses being fetched. I do not have that result yet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the four pages is now the &lt;a href="https://pst.aivismonitor.com/eml-to-pdf-converter" rel="noopener noreferrer"&gt;EML to PDF converter&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Source note (2026-11-13): I read Mailward commit 1f8960f (AuthorDate 2026-11-11 10:32:30 +0800), the current permanent redirects, the four registry paths, and the new assertions in &lt;code&gt;tests/tool-pages.test.ts&lt;/code&gt;. I did not run the test suite, and I did not re-open Search Console or Bing Webmaster. I did confirm the live 200 and the two 308s myself.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>seo</category>
      <category>nextjs</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Article Already Had an og:image. Its JSON-LD Didn't Mention It.</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Wed, 11 Nov 2026 02:12:09 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/the-article-already-had-an-ogimage-its-json-ld-didnt-mention-it-4c80</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/the-article-already-had-an-ogimage-its-json-ld-didnt-mention-it-4c80</guid>
      <description>&lt;p&gt;I maintain three long-form pages that already emit JSON-LD: a format guide typed as &lt;code&gt;Article&lt;/code&gt;, and two technical write-ups typed as &lt;code&gt;TechArticle&lt;/code&gt;. Each page also sets a 1200×630 &lt;code&gt;og:image&lt;/code&gt; through the site's shared social-metadata helper.&lt;/p&gt;

&lt;p&gt;A weekly structured-data pass, recorded in the commit this post is based on, found that none of the three JSON-LD nodes had an &lt;code&gt;image&lt;/code&gt; property. The picture was already on the page. It just was not in the article markup.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the docs recommend
&lt;/h2&gt;

&lt;p&gt;I opened Google's &lt;a href="https://developers.google.com/search/docs/appearance/structured-data/article" rel="noopener noreferrer"&gt;Article structured data&lt;/a&gt; documentation while writing this. A few points matter, and I want to quote them as recommendations, not as guarantees:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There are no required properties. &lt;code&gt;image&lt;/code&gt; is in the &lt;strong&gt;recommended&lt;/strong&gt; list: a representative image, as a URL or &lt;code&gt;ImageObject&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Image URLs must be crawlable and indexable, and "for best results" Google recommends high-resolution images of at least 50,000 pixels when width is multiplied by height, ideally in 16×9, 4×3, and 1×1.&lt;/li&gt;
&lt;li&gt;Google does not guarantee that features which consume structured data will appear in search results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The 1200×630 social image is 756,000 pixels, which clears the 50,000-pixel floor. The site still serves only that one picture, not the three aspect ratios in the "best results" note. I am not claiming this change produces a rich result.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual gap
&lt;/h2&gt;

&lt;p&gt;The social image and the JSON-LD lived in two places. &lt;code&gt;OG_IMAGE&lt;/code&gt; in &lt;code&gt;social-metadata.ts&lt;/code&gt; already described the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;OG_IMAGE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/og.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;630&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Mailward — open PST, OST, OLM, MBOX and EML archives in your browser, nothing uploaded"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(The &lt;code&gt;export&lt;/code&gt; is new. Until this change, the object was file-private, because only the Open Graph tags needed it.)&lt;/p&gt;

&lt;p&gt;The article nodes already had &lt;code&gt;headline&lt;/code&gt;, dates, &lt;code&gt;author&lt;/code&gt;, &lt;code&gt;publisher&lt;/code&gt;, and &lt;code&gt;mainEntityOfPage&lt;/code&gt;. They did not have &lt;code&gt;image&lt;/code&gt;. An &lt;code&gt;og:image&lt;/code&gt; tag does not fill that property for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  One helper, so the two cannot drift
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;articleImage()&lt;/code&gt; turns the same relative path into an absolute URL, which is what the JSON-LD field needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="no"&gt;OG_IMAGE&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"./social-metadata"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** The articles' Article/TechArticle `image`: the same 1200×630 picture
 * their og:image already shows, as an absolute URL. */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;articleImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;getCanonicalUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;OG_IMAGE&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;getCanonicalUrl&lt;/code&gt; prefixes the path with &lt;code&gt;NEXT_PUBLIC_BASE_URL&lt;/code&gt;, or with the site's default origin. For &lt;code&gt;/og.png&lt;/code&gt; that becomes an absolute URL on that origin.&lt;/p&gt;

&lt;p&gt;Each of the three pages then adds one field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;jsonLd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"@context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://schema.org"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"@type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Article"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// or "TechArticle" on the other two pages&lt;/span&gt;
  &lt;span class="n"&gt;headline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;TITLE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// …&lt;/span&gt;
  &lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;articleImage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;mainEntityOfPage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;getCanonicalUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/email-archive-formats"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the social image path ever changes, the structured data follows it, because both read &lt;code&gt;OG_IMAGE&lt;/code&gt;. That is the point of the helper. Duplicating the string &lt;code&gt;"/og.png"&lt;/code&gt; in &lt;code&gt;seo.ts&lt;/code&gt; would have closed the gap today and invited it to open again later.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the test pins — and what it does not
&lt;/h2&gt;

&lt;p&gt;The new test in &lt;code&gt;tests/structured-data.test.ts&lt;/code&gt; checks three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;articleImage()&lt;/code&gt; equals &lt;code&gt;getCanonicalUrl("/og.png")&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OG_IMAGE.width * OG_IMAGE.height&lt;/code&gt; is at least 50,000&lt;/li&gt;
&lt;li&gt;each of the three page files contains the literal &lt;code&gt;image: articleImage(),&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I read that test. I did not run the suite for this post. The test does not parse rendered HTML or call Google's Rich Results Test; it pins the source and the pixel arithmetic.&lt;/p&gt;

&lt;p&gt;Two other limits I do not want to blur:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Google page I opened lists &lt;code&gt;Article&lt;/code&gt;, &lt;code&gt;NewsArticle&lt;/code&gt;, and &lt;code&gt;BlogPosting&lt;/code&gt; as the types Article markup should be based on. Two of these pages use &lt;code&gt;TechArticle&lt;/code&gt;. I am not treating that as the same documented type.&lt;/li&gt;
&lt;li&gt;The shared social image is a site-wide Open Graph picture, not a photograph unique to each article. The docs prefer an image that represents the article rather than a logo. I did not re-evaluate whether this file meets that wording.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The commit also moves those three pages' sitemap dates, because the page files changed. I am not making a separate claim about how Google treats &lt;code&gt;lastmod&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;code&gt;og:image&lt;/code&gt; and an Article &lt;code&gt;image&lt;/code&gt; are different slots. Filling one does not fill the other.&lt;/li&gt;
&lt;li&gt;If the two should be the same picture, give them one source. A helper that reads the social-image constant is cheaper than a comment saying "keep these in sync."&lt;/li&gt;
&lt;li&gt;Use an absolute URL in the JSON-LD. The Open Graph path can stay relative; &lt;code&gt;getCanonicalUrl&lt;/code&gt; is enough to derive the other.&lt;/li&gt;
&lt;li&gt;Pin the URL, the 50,000-pixel floor, and the call sites. That is what will regress, not a screenshot of a rich result that may never appear.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the three pages is the &lt;a href="https://pst.aivismonitor.com/email-archive-formats" rel="noopener noreferrer"&gt;email archive formats guide&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Source note (2026-11-11): I read Mailward commit b37ee2c (AuthorDate 2026-11-11 09:27:13 +0800), the current &lt;code&gt;articleImage()&lt;/code&gt; in &lt;code&gt;src/lib/seo.ts&lt;/code&gt;, the exported &lt;code&gt;OG_IMAGE&lt;/code&gt; in &lt;code&gt;src/lib/social-metadata.ts&lt;/code&gt;, the three article pages' JSON-LD objects, and the new assertions in &lt;code&gt;tests/structured-data.test.ts&lt;/code&gt; on the Mac. I also opened Google's Article structured data documentation the same day. I did not run the test suite or Google's Rich Results Test.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>seo</category>
      <category>nextjs</category>
      <category>jsonld</category>
    </item>
    <item>
      <title>The HTML File Wasn't a Failed Download. The Error Message Assumed It Was.</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Tue, 10 Nov 2026 02:08:17 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/the-html-file-wasnt-a-failed-download-the-error-message-assumed-it-was-1kob</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/the-html-file-wasnt-a-failed-download-the-error-message-assumed-it-was-1kob</guid>
      <description>&lt;p&gt;I build a browser tool that opens mail archives locally. Before a file is parsed as a PST, MBOX or EML, a short sniff looks at the first bytes and, when they are not mail, the UI shows a hint for that kind.&lt;/p&gt;

&lt;p&gt;For files sniffed as &lt;code&gt;html&lt;/code&gt;, the hint used to cover only one explanation: the page a sharing or download link returns when it needs a sign-in or has expired.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the commit records
&lt;/h2&gt;

&lt;p&gt;A visitor dropped the same 1–10 MB file four times in a minute. Each time it sniffed as &lt;code&gt;html&lt;/code&gt;. They left after seeing only the sign-in / expired-link explanation.&lt;/p&gt;

&lt;p&gt;I did not open that visitor's file, and I did not watch the session. The size range, the four attempts, and the fact that they left come from the commit message. What I can confirm from the source is the hint they would have been shown, and how &lt;code&gt;html&lt;/code&gt; is detected.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a drop becomes &lt;code&gt;html&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The sniffer does not look at the file name. After skipping an optional UTF-8 BOM and leading whitespace, it checks for an ASCII, case-insensitive &lt;code&gt;&amp;lt;!DOCTYPE html&lt;/code&gt; or &lt;code&gt;&amp;lt;html&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;looksLikeHtml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mh"&gt;0x20&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mh"&gt;0x09&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mh"&gt;0x0a&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mh"&gt;0x0d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromCharCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subarray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;!doctype html"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;html"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Existing tests already pin three shapes: a &lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/code&gt; page titled "Sign in", a leading-whitespace &lt;code&gt;&amp;lt;HTML&amp;gt;&lt;/code&gt; page that says "Link expired", and the same doctype behind a UTF-8 BOM. A stray &lt;code&gt;&amp;lt;note&amp;gt;…&amp;lt;/note&amp;gt;&lt;/code&gt; document is still &lt;code&gt;text&lt;/code&gt;, not &lt;code&gt;html&lt;/code&gt;. I read those assertions in &lt;code&gt;tests/sniff.test.ts&lt;/code&gt;. I did not run the suite for this post.&lt;/p&gt;

&lt;p&gt;That detection is doing its job. The miss was in the sentence that followed it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The old hint named only one cause
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"html"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"The content is a web page, which is what a sharing or download link returns instead of the file when it needs a sign-in or has expired. Download the archive again from the source and check the size matches."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is a real case: a dead link often yields a small HTML page, and "download it again and check the size" is the right next step. It is the wrong next step when the visitor already has the file they meant to drop, and that file is itself a web page.&lt;/p&gt;

&lt;p&gt;The commit's reasoning is size. A sign-in or expiry page is typically a few kilobytes. A file in the 1–10 MB range is far more likely a page or a message the browser saved as &lt;code&gt;.html&lt;/code&gt; / &lt;code&gt;.htm&lt;/code&gt;. I am not treating that as a measurement I took; it is the reason written in the commit and in the source comment.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed — and what did not
&lt;/h2&gt;

&lt;p&gt;The hint now adds the second case, still in the same &lt;code&gt;html&lt;/code&gt; branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"html"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"The content is a web page, which is what a sharing or download link returns instead of the file when it needs a sign-in or has expired. Download the archive again from the source and check the size matches. A page or message saved from a browser (.html, .htm) is not a mail archive either: open it in the browser, or save the message from your mail program as .eml (in Gmail: ⋮ → Download message), which Mailward opens."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things this change does &lt;em&gt;not&lt;/em&gt; do, and I want to be exact about them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It does &lt;strong&gt;not&lt;/strong&gt; branch on file size. Every drop sniffed as &lt;code&gt;html&lt;/code&gt; now gets both explanations. Size is why the second sentence was added, not a condition in the code.&lt;/li&gt;
&lt;li&gt;It does &lt;strong&gt;not&lt;/strong&gt; open a saved &lt;code&gt;.html&lt;/code&gt; message as mail. The hint says the opposite: that file is not a mail archive. The suggested path is to open the page in a browser, or to export the message as &lt;code&gt;.eml&lt;/code&gt;, which this tool does open.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The new test assertions only check that the &lt;code&gt;html&lt;/code&gt; hint contains "saved from a browser" and ".eml", alongside the older "web page" and "Download the archive again" checks. They do not assert a size threshold, because there isn't one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A content sniff can be right and the hint still wrong, if the hint names only the cause you thought of first.&lt;/li&gt;
&lt;li&gt;Expired-link HTML and a browser-saved page share the same magic bytes. If you mention one, mention the other.&lt;/li&gt;
&lt;li&gt;If size is only a reason for writing the copy, say so in a comment; do not imply the UI classifies by size unless the code does.&lt;/li&gt;
&lt;li&gt;When the file is the thing the visitor saved, "download it again" is a dead end. Tell them what the file actually is, and what format would open.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The format the hint points at is an &lt;code&gt;.eml&lt;/code&gt; file. The page that opens one is the &lt;a href="https://pst.aivismonitor.com/eml-viewer" rel="noopener noreferrer"&gt;EML viewer&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Source note (2026-11-10): I read Mailward commit b8673f0 (AuthorDate 2026-11-10 09:20:25 +0800), the current &lt;code&gt;src/lib/sniff.ts&lt;/code&gt; (&lt;code&gt;looksLikeHtml&lt;/code&gt;, the &lt;code&gt;html&lt;/code&gt; branch of &lt;code&gt;renameHintFor&lt;/code&gt;), and the related assertions in &lt;code&gt;tests/sniff.test.ts&lt;/code&gt; on the Mac. I did not run the test suite, did not open the visitor's file, and did not re-measure the session.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>email</category>
      <category>html</category>
    </item>
    <item>
      <title>Opening an Outlook PST on Its Inbox Without Matching the Name "Inbox"</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Sun, 08 Nov 2026 02:13:05 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/opening-an-outlook-pst-on-its-inbox-without-matching-the-name-inbox-2ak8</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/opening-an-outlook-pst-on-its-inbox-without-matching-the-name-inbox-2ak8</guid>
      <description>&lt;p&gt;I build a browser tool that reads Outlook &lt;code&gt;.pst&lt;/code&gt; and &lt;code&gt;.ost&lt;/code&gt; files locally. After a file opens, the UI has to select &lt;em&gt;some&lt;/em&gt; folder. For a while the rule was: &lt;strong&gt;select the first folder that has any messages.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On one fixture that rule picked the wrong folder, and the obvious fix (look for a folder named "Inbox") has a problem of its own. This post covers the replacement: a heuristic, what it's based on, and where it stops.&lt;/p&gt;

&lt;h2&gt;
  
  
  The failure
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;pst-extractor&lt;/code&gt;'s public test OST is a small Outlook.com cache in the 4 KB-page layout. In its folder tree, the first folder with mail is &lt;strong&gt;Deleted Items&lt;/strong&gt; (one deleted invitation). The Inbox, with ten messages, comes after it. So "first folder with mail" opened the archive on a deleted invitation.&lt;/p&gt;

&lt;p&gt;That's one fixture. I'm not claiming every OST is ordered that way. It was enough to show that "first folder with mail" depends on an order the file doesn't promise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not match the name
&lt;/h2&gt;

&lt;p&gt;Special-folder display names are localized, so the Inbox isn't necessarily called "Inbox". Matching a list of translations would also match user-created folders that happen to have one of those names. I wanted a signal that doesn't come from the display name.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the spec describes
&lt;/h2&gt;

&lt;p&gt;Microsoft's Special Folders Protocol, &lt;strong&gt;[MS-OXOSFLD] section 2.2.3, "Binary Identification Properties"&lt;/strong&gt;, lists binary properties that each hold the entry ID of a special folder: Calendar, Contacts, Journal, Notes, Tasks, Reminders and Drafts. The copy of the spec I read (the June 2016 PDF release, v20160613) says these properties "are read from or written to either the Inbox folder or the Root folder". Per that copy, the Inbox is used for the owner's mailbox and the Root folder for a delegate's. I haven't compared that wording against the current revision of the spec.&lt;/p&gt;

&lt;p&gt;Note what the spec does &lt;em&gt;not&lt;/em&gt; say: that a folder carrying these properties is the Inbox. It describes where clients store the entry IDs of &lt;em&gt;other&lt;/em&gt; folders. Using that in reverse to spot the Inbox is my inference.&lt;/p&gt;

&lt;h2&gt;
  
  
  The heuristic
&lt;/h2&gt;

&lt;p&gt;In the project's folder-tree builder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;NID_ROOT_FOLDER&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x122&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;SPECIAL_FOLDER_ID_PROPS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mh"&gt;0x36d0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x36d1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x36d2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x36d3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x36d4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x36d7&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;carriesSpecialFolderIds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PSTFolder&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folder&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;unknown&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;pstTableItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;pstTableItems&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;SPECIAL_FOLDER_ID_PROPS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// while building each folder node:&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;NID_ROOT_FOLDER&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nf"&gt;carriesSpecialFolderIds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folder&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isInbox&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The set covers six of the properties in that table (Calendar, Contacts, Journal, Notes, Tasks, Drafts). The root folder is excluded because the spec puts the same properties there too. Any other folder that has at least one of them is treated as the Inbox.&lt;/p&gt;

&lt;p&gt;A few honest notes about this code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It reaches into &lt;code&gt;pst-extractor&lt;/code&gt;'s internal &lt;code&gt;pstTableItems&lt;/code&gt; map through a cast. That's a dependency on a library internal, and it could break on an upgrade.&lt;/li&gt;
&lt;li&gt;I've confirmed &lt;code&gt;0x36D0&lt;/code&gt; (PidTagIpmAppointmentEntryId) against Microsoft's MAPI reference. The other five tag values come from the project's source, and I didn't check each of them against an official table for this post.&lt;/li&gt;
&lt;li&gt;It flags &lt;em&gt;every&lt;/em&gt; non-root folder that carries one of the properties. In the two fixtures below that have a marked Inbox, exactly one non-root folder qualified; the Enron fixture had none. A file where several do, or where the wrong folder does, would get a wrong guess.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The open rule, with the fallback
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;openingFolder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PstFolderNode&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;PstFolderNode&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;flattenFolders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isInbox&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messageCount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt;
    &lt;span class="nx"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;messageCount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt;
    &lt;span class="kc"&gt;null&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prefer the flagged Inbox &lt;strong&gt;only if it has mail&lt;/strong&gt;. Otherwise fall back to the old rule. The fallback isn't a safety net I hope never to use; two of the three fixtures need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three fixtures
&lt;/h2&gt;

&lt;p&gt;The commit adds one test per fixture:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fixture&lt;/th&gt;
&lt;th&gt;Folder(s) flagged &lt;code&gt;isInbox&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Opens on&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;pst-extractor&lt;/code&gt; 4 KB-page test OST&lt;/td&gt;
&lt;td&gt;Inbox&lt;/td&gt;
&lt;td&gt;Inbox (10 messages), not Deleted Items&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;dist-list.pst&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inbox (root not flagged)&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Calendar&lt;/strong&gt;, because the flagged Inbox is empty&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;enron.pst&lt;/code&gt; (an exported subset)&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;first folder with mail, &lt;code&gt;MLOKAY (Non-Privileged)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;According to the commit message, the test goes red without the flag. I read the test code; I didn't run it for this post.&lt;/p&gt;

&lt;p&gt;Three fixtures is a small sample. The test assertions cover both the heuristic and the fallback; I have not rerun them here. They don't show the heuristic is right on arbitrary PST and OST files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;"First folder with mail" depends on folder order. Display names depend on language. Neither is a stable signal.&lt;/li&gt;
&lt;li&gt;The special-folder entry IDs described in [MS-OXOSFLD] 2.2.3 give a language-independent clue for spotting the Inbox. Treat it as a heuristic you built, not a rule the spec promises.&lt;/li&gt;
&lt;li&gt;Exclude the root folder, which carries the same properties.&lt;/li&gt;
&lt;li&gt;Only prefer the flagged folder when it has mail, and keep "first folder with mail" as the fallback.&lt;/li&gt;
&lt;li&gt;Test on files that exercise each branch: flagged with mail, flagged but empty, and nothing flagged.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The viewer that uses this is the &lt;a href="https://pst.aivismonitor.com/ost-viewer" rel="noopener noreferrer"&gt;OST viewer&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Source note: I read commit 7c40c5d (2026-10-19), the current &lt;code&gt;archive.ts&lt;/code&gt; and &lt;code&gt;folder-tree.ts&lt;/code&gt;, and the commit's test diff on 2026-11-08. I didn't run the test suite. The [MS-OXOSFLD] quotes are from the June 2016 PDF release, not the current online revision.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>outlook</category>
      <category>email</category>
    </item>
    <item>
      <title>Two Things Every CSV Export of Untrusted Text Needs Before Someone Double-Clicks It in Excel</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Thu, 05 Nov 2026 02:09:20 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/two-things-every-csv-export-of-untrusted-text-needs-before-someone-double-clicks-it-in-excel-h38</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/two-things-every-csv-export-of-untrusted-text-needs-before-someone-double-clicks-it-in-excel-h38</guid>
      <description>&lt;p&gt;I build a browser tool that reads email archives and can export a mailbox as a CSV index: one row per message with date, sender name, sender address, subject and an attachments flag. People use it to get a mailbox "into Excel".&lt;/p&gt;

&lt;p&gt;That export shipped with two bugs that never showed up in a text editor. Both appear only when someone double-clicks the file and Excel opens it. Here they are and how I fixed them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: Excel doesn't assume UTF-8
&lt;/h2&gt;

&lt;p&gt;My CSV was valid UTF-8. Opened in VS Code, &lt;code&gt;Grüße&lt;/code&gt; and &lt;code&gt;日本語&lt;/code&gt; looked fine. Double-clicked in Excel, they came out as mojibake.&lt;/p&gt;

&lt;p&gt;The reason: when Excel opens a CSV directly, it decodes it in the system's ANSI code page &lt;strong&gt;unless the file starts with a UTF-8 byte-order mark&lt;/strong&gt;. Subjects and sender names in real mail are full of accented and non-Latin characters, so this hits almost every real mailbox.&lt;/p&gt;

&lt;p&gt;The fix is three bytes, &lt;code&gt;EF BB BF&lt;/code&gt;, at the very start of the file. I put it in one function that every CSV download goes through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CSV_UTF8_BOM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;ufeff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="cm"&gt;/** The bytes of a CSV download — every CSV this app writes goes through here. */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;csvBytes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Uint8Array&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TextEncoder&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CSV_UTF8_BOM&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;TextEncoder&lt;/code&gt; writes U+FEFF as the three-byte UTF-8 sequence, so the file starts with exactly what Excel looks for.&lt;/p&gt;

&lt;p&gt;The important part is the single choke point. There were three CSV downloads: one folder, the whole archive, and search results. The search-results export was built in the UI rather than in the worker. One of them going out without the BOM was the real risk. The test reads the source files and asserts that all three call sites use &lt;code&gt;csvBytes()&lt;/code&gt;, and that no plain &lt;code&gt;encoder.encode(csv)&lt;/code&gt; remains.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 2: other people's text can be a formula
&lt;/h2&gt;

&lt;p&gt;The cells in this CSV aren't mine. They're email subjects, sender names and folder or label names, all typed by whoever sent or organised the mail. A subject line like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=HYPERLINK("http://example.com/x","Invoice")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;was written into the CSV verbatim. Spreadsheet apps (Excel, LibreOffice, Google Sheets) read a cell that starts with &lt;code&gt;=&lt;/code&gt; as a formula. That's &lt;strong&gt;CSV injection&lt;/strong&gt; (also called formula injection). OWASP has a page on it, and the classic proof-of-concept payload is something like &lt;code&gt;-2+3+cmd|' /C calc'!A0&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The trigger isn't only &lt;code&gt;=&lt;/code&gt;. OWASP's list of leading characters is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;=&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;+&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;@&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;tab (&lt;code&gt;\t&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;carriage return (&lt;code&gt;\r&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The recommended mitigation is to prefix such a value with a single quote (&lt;code&gt;'&lt;/code&gt;), which spreadsheets treat as "this is text".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;FORMULA_START&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;=+&lt;/span&gt;&lt;span class="se"&gt;\-&lt;/span&gt;&lt;span class="sr"&gt;@&lt;/span&gt;&lt;span class="se"&gt;\t\r]&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;FORMULA_START&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;`'&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;[&lt;/span&gt;&lt;span class="sr"&gt;",&lt;/span&gt;&lt;span class="se"&gt;\r\n]&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;`"&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/"/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;""&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;"`&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Order matters: guard first, quote second. The apostrophe has to end up &lt;em&gt;inside&lt;/em&gt; the quoted field, so a value that both starts with &lt;code&gt;=&lt;/code&gt; and contains a comma becomes &lt;code&gt;"'=…, …"&lt;/code&gt;. If you quote first and then prepend, the apostrophe ends up outside the quotes and the field is malformed.&lt;/p&gt;

&lt;p&gt;The quoting itself is plain RFC 4180: wrap the field in double quotes if it contains a comma, a double quote or a line break, and double any embedded quotes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost, stated plainly
&lt;/h2&gt;

&lt;p&gt;This guard isn't free. An honest subject like &lt;code&gt;-- weekly report&lt;/code&gt; or &lt;code&gt;+1 for Friday&lt;/code&gt; now shows a leading apostrophe in some views. That's the trade OWASP recommends, and I'd rather have a stray apostrophe than a formula that runs. But users will see it, so the page that describes the export says so, instead of letting someone discover it and think the export is broken.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make it impossible to bypass
&lt;/h2&gt;

&lt;p&gt;Before this change, the code had two private escaper functions, each with its own idea of what to quote. That's how one path ends up guarded and another doesn't. They're gone. Every text cell in all three export paths now goes through &lt;code&gt;csvCell()&lt;/code&gt;, and a test checks that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;neutralises every formula trigger&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;=1+1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'=1+1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+1 Sales&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'+1 Sales&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;-2+3+cmd|' /C calc'!A0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'-2+3+cmd|' /C calc'!A0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@SUM(A1:A9)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'@SUM(A1:A9)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;=1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;=1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\r&lt;/span&gt;&lt;span class="s2"&gt;=1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`"'\r=1"`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;csvCell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;=HYPERLINK("http://example.com/x","Invoice")&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toBe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`"'=HYPERLINK(""http://example.com/x"",""Invoice"")"`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other tests cover values that should be left alone, run a crafted mailbox through both exporters, and grep the exporter and the UI to make sure every text field goes through &lt;code&gt;csvCell&lt;/code&gt; and no private escaper is back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The apostrophe prefix is a mitigation for spreadsheet apps, not a general sanitiser. If your CSV is consumed by another program that does its own interpretation, check what that program treats as special.&lt;/li&gt;
&lt;li&gt;The BOM is what Excel needs on a double-click. Some strict CSV parsers treat it as part of the first header name, so if your CSV also feeds a pipeline, make sure that consumer strips it.&lt;/li&gt;
&lt;li&gt;Dates are written as ISO 8601 in UTC, which sorts correctly as text. Excel may or may not convert them to its own date type depending on locale. That's a separate problem I didn't try to solve here.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Prepend a UTF-8 BOM to any CSV a person will double-click.&lt;/li&gt;
&lt;li&gt;Prefix values starting with &lt;code&gt;= + - @ \t \r&lt;/code&gt; with &lt;code&gt;'&lt;/code&gt;, then apply RFC 4180 quoting, in that order.&lt;/li&gt;
&lt;li&gt;Route every CSV path through one encoder and one cell function, and test that nothing bypasses them.&lt;/li&gt;
&lt;li&gt;Tell users about the visible apostrophe.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to see what the export looks like on a real mailbox, the &lt;a href="https://pst.aivismonitor.com/mbox-viewer" rel="noopener noreferrer"&gt;MBOX viewer page&lt;/a&gt; explains the CSV index and what goes into each column. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>security</category>
      <category>csv</category>
      <category>excel</category>
    </item>
    <item>
      <title>Upstream Shipped a Corruption Fix. Does Updating Repair a Damaged File? How I Decided What My Tool Should Claim</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Tue, 03 Nov 2026 02:12:34 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/upstream-shipped-a-corruption-fix-does-updating-repair-a-damaged-file-how-i-decided-what-my-tool-3e4f</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/upstream-shipped-a-corruption-fix-does-updating-repair-a-damaged-file-how-i-decided-what-my-tool-3e4f</guid>
      <description>&lt;p&gt;Audacity 4.0.2 came out on 2 November 2026, a fix release ahead of 4.1. I maintain a browser tool that reads, recovers and downgrades Audacity project files, so a new upstream release raises two questions the same day:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Did anything change that my code depends on?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What will people now ask, and what can I truthfully answer?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This post is about how I answered both, because "just update the copy" is how a tool ends up making claims that quietly go stale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Question 1: did the format gates move?
&lt;/h2&gt;

&lt;p&gt;My downgrade feature exists because Audacity 3.7 refuses a newer project at exactly two gates, both checked before it reads a single track:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SQLite's &lt;code&gt;PRAGMA user_version&lt;/code&gt;, a packed &lt;code&gt;Major&amp;lt;&amp;lt;24 | Minor&amp;lt;&amp;lt;16 | Revision&amp;lt;&amp;lt;8 | ModLevel&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;version&lt;/code&gt; attribute on the project document's root, the XML schema version. Audacity 4 writes &lt;code&gt;2.0.0&lt;/code&gt;; the downgrade rewrites it to a value 3.7 accepts.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If 4.0.2 changed either, the downgrade would need new code. So instead of guessing from release notes, I read the compare between the 4.0.1 and 4.0.2 tags. Per my notes from that read:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It touches &lt;code&gt;ProjectFileIO.cpp&lt;/code&gt; (compaction keeps the saved document's blocks; &lt;code&gt;WriteXML&lt;/code&gt; drops its recording flag), plus &lt;code&gt;Sequence&lt;/code&gt; and &lt;code&gt;WaveTrack&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It does &lt;strong&gt;not&lt;/strong&gt; touch &lt;code&gt;AUDACITY_FILE_FORMAT_VERSION&lt;/code&gt;, which is still &lt;code&gt;"2.0.0"&lt;/code&gt; at the 4.0.2 tag, nor the version files of the embedded &lt;code&gt;au3-project&lt;/code&gt; libraries, nor &lt;code&gt;WaveClip.cpp&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last file matters because the downgrade also rewrites some clip attributes. Not touching it means those rewrites are as they were in 4.0.1. The downgrade code compares versions generically, so it needed no change.&lt;/p&gt;

&lt;p&gt;The useful habit: &lt;strong&gt;name the specific files and constants your code depends on, and check those in the compare.&lt;/strong&gt; "The release notes don't mention format changes" is weaker than "the one constant I rely on is identical at both tags."&lt;/p&gt;

&lt;h2&gt;
  
  
  Question 2: "Does updating repair my project?"
&lt;/h2&gt;

&lt;p&gt;A fix release called out corruption fixes, so I expected people to ask whether installing it repairs files that are already damaged. The short answer I put on the page is &lt;strong&gt;no&lt;/strong&gt;: an update stops damage from happening again; a file already damaged stays as it is.&lt;/p&gt;

&lt;p&gt;What the fixes were, as the pull requests describe them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PR 12544:&lt;/strong&gt; before the fix, a clip one sample long was removed on load, and its samples were removed from the sample-block table, while the saved project document still referenced them. A later open then points at a block that doesn't exist.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PR 12539:&lt;/strong&gt; Audacity 4 never called for autosave while recording. The fix restores it. A crash mid-take in an earlier version therefore left an autosave copy that doesn't contain that take.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first bug produces exactly the failure a recovery tool sees: a document that references a missing sample block. What can the tool do about it?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It can report the missing block, and the number of samples it estimates are gone.&lt;/li&gt;
&lt;li&gt;It can play and export the project with that gap as &lt;strong&gt;silence&lt;/strong&gt;. Audacity encodes silence as a non-positive block id meaning "that many samples of nothing", so a rebuilt project can fill the hole in a form Audacity understands.&lt;/li&gt;
&lt;li&gt;It &lt;strong&gt;cannot&lt;/strong&gt; bring back audio that was deleted from the block table. That audio isn't in the file any more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Don't claim more than the code does
&lt;/h2&gt;

&lt;p&gt;This is the part I care about most. It's easy to write "recovers your audio". It's more accurate to write what the code actually does. The tool plays what a saved, autosaved or earlier document places on the timeline. A sample block that no document references is &lt;strong&gt;counted but never mixed&lt;/strong&gt;. Someone who needs those orphaned blocks should use the official command-line tool's option that writes a file's sample blocks out as WAV files without needing a document.&lt;/p&gt;

&lt;p&gt;So the page says that, in those words, and names the other tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pin the copy to the code
&lt;/h2&gt;

&lt;p&gt;The risk with a page like this is drift: someone changes &lt;code&gt;recover.ts&lt;/code&gt;, and the FAQ still promises the old behaviour. So tests read the page and the code together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;promises silence for a missing block only because the report and rebuild do that&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;recover&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SRC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aup&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;recover.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toContain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;will be filled with silence&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;faq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toContain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;the gap plays and exports as silence&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;it&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;never claims the page lifts audio no document places&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;faq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toContain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;plays what a saved, autosaved or earlier document places on the timeline&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;recover&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SRC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aup&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;recover.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;recover&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toContain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;orphanBlockCount: health.orphanBlockCount&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// counted...&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timeline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SRC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lib&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aup&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;timeline.ts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;utf8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeline&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;not&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toMatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/orphan/i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;                                   &lt;span class="c1"&gt;// ...never mixed&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other tests pin the version claim: the page quotes the document version it rewrites, and that quote is compared with the exported constant the downgrade uses, so changing one without the other fails the build. The same facts are also mirrored into the machine-readable summary the site publishes for AI assistants, and tests check that too.&lt;/p&gt;

&lt;p&gt;These are string-level tests, so they are crude. They catch a claim drifting away from the code, not whether the claim was right in the first place. For that, the sources (the release page, both pull requests, the tagged source file) are listed on the page so a reader can check them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I read the compare between the two tags on the day of release. A later point release can change the answer, which is why the pages cite tag names and dates rather than "the latest version".&lt;/li&gt;
&lt;li&gt;"No" to "does updating repair my project?" is about files already damaged. It doesn't say anything about whether a particular file is damaged.&lt;/li&gt;
&lt;li&gt;I haven't reproduced the upstream bugs myself; the description of them comes from the pull requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When upstream ships, list the files and constants &lt;strong&gt;you&lt;/strong&gt; depend on and check exactly those in the diff between tags.&lt;/li&gt;
&lt;li&gt;Answer the "will updating fix it?" question directly. Prevention and repair are different, and users conflate them.&lt;/li&gt;
&lt;li&gt;Say what your tool can't recover, and point at a tool that can.&lt;/li&gt;
&lt;li&gt;Make tests read both the copy and the code, so a claim can't outlive the behaviour behind it.&lt;/li&gt;
&lt;li&gt;Date everything, and cite tags, not "latest".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to see how the page words it, it's the &lt;a href="https://aup4.aivismonitor.com/recover-audacity-project" rel="noopener noreferrer"&gt;Audacity project recovery page&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt; Projects are read in your browser and aren't uploaded.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>testing</category>
      <category>webdev</category>
      <category>audio</category>
    </item>
    <item>
      <title>Why My iPhone File Picker Greyed Out Every PST File I Asked For</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Mon, 02 Nov 2026 02:06:50 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/why-my-iphone-file-picker-greyed-out-every-pst-file-i-asked-for-46k9</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/why-my-iphone-file-picker-greyed-out-every-pst-file-i-asked-for-46k9</guid>
      <description>&lt;p&gt;&lt;em&gt;WebKit maps &lt;code&gt;accept&lt;/code&gt; extensions to MIME types, drops the ones it doesn't know, and then limits the Files app to whatever is left. For a mail archive tool, that is almost everything that matters.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;I run a browser tool that opens Outlook &lt;code&gt;.pst&lt;/code&gt; and &lt;code&gt;.ost&lt;/code&gt; files without Outlook. For months the homepage said it worked on a Mac, a PC, a Chromebook, or an Android phone. Google was suggesting "open pst file on ipad" next to "on android" and "on chromebook". Bing showed tablet-flavoured queries. The site said nothing about an iPad or an iPhone.&lt;/p&gt;

&lt;p&gt;That gap was not just marketing. On iOS the file picker itself can quietly refuse the files the page is built for. Here is what I measured, why the picker behaves that way, and what the page now does about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, does the engine even open a PST?
&lt;/h2&gt;

&lt;p&gt;Before writing any "works on iPad" claim, I ran the live site in Playwright's WebKit 26.6 with the iPad Pro 11 and iPhone 15 profiles. That is Apple's engine in an emulated viewport, not a physical iPad's memory or its Files UI, so the claim has to stay within what that run shows.&lt;/p&gt;

&lt;p&gt;Results with the public Enron test PST (14 MB, read whole) and a 108 MB copy (read in pages):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;11 folders and 71 messages opened in about 0.8 seconds&lt;/li&gt;
&lt;li&gt;search returned hits&lt;/li&gt;
&lt;li&gt;tapping a message opened it&lt;/li&gt;
&lt;li&gt;no page errors, no sideways scroll&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the readers work in WebKit. PST, OST and MBOX are read in pages rather than held whole in memory, which is the same path Android and desktop use for large files. That is the engine half of the story. The picker is the other half.&lt;/p&gt;

&lt;h2&gt;
  
  
  What &lt;code&gt;&amp;lt;input accept=".pst,.ost,…"&amp;gt;&lt;/code&gt; does on iOS
&lt;/h2&gt;

&lt;p&gt;On iPhone and iPad every browser is WebKit. When a page sets the file input's &lt;code&gt;accept&lt;/code&gt; attribute to a list of extensions, WebKit does &lt;strong&gt;not&lt;/strong&gt; pass those extensions through to the Files app as filenames. It looks each one up in the system's extension-to-MIME table and &lt;strong&gt;drops&lt;/strong&gt; any extension that has no entry.&lt;/p&gt;

&lt;p&gt;Of the archive types this tool accepts:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Extension&lt;/th&gt;
&lt;th&gt;iOS has a MIME mapping?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.eml&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;yes (&lt;code&gt;message/rfc822&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;.zip&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;yes (&lt;code&gt;application/zip&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;.pst&lt;/code&gt;, &lt;code&gt;.ost&lt;/code&gt;, &lt;code&gt;.olm&lt;/code&gt;, &lt;code&gt;.mbox&lt;/code&gt;, &lt;code&gt;.msg&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;no&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If &lt;em&gt;anything&lt;/em&gt; survives that lookup, the Files picker opens &lt;strong&gt;limited to the survivors&lt;/strong&gt;. A homepage that listed &lt;code&gt;.pst,.ost,.eml,.mbox,…&lt;/code&gt; therefore opened a picker in which every archive type but &lt;code&gt;.eml&lt;/code&gt; and &lt;code&gt;.zip&lt;/code&gt; was greyed out — including the &lt;code&gt;.pst&lt;/code&gt; the visitor came to open.&lt;/p&gt;

&lt;p&gt;If &lt;em&gt;nothing&lt;/em&gt; survives, the picker allows every file. So the failure mode is not "no &lt;code&gt;accept&lt;/code&gt; breaks iOS". It is "a mixed list that includes one known type silently filters out every unknown type".&lt;/p&gt;

&lt;p&gt;(The WebKit side of this lives in &lt;code&gt;WKFileUploadPanel&lt;/code&gt; and the Cocoa MIME registry: extensions go through UTI / MIME lookup before the menu is shown. I am not claiming a new WebKit bug; I am describing the behaviour a page has to work around.)&lt;/p&gt;

&lt;p&gt;This matched older analytics too: across ninety days there had been iOS visitors and zero successful opens. The engine was fine. The picker was the wall.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule the page uses now
&lt;/h2&gt;

&lt;p&gt;The accept string is built by a small helper. On an Apple touch device it is kept only when &lt;strong&gt;every&lt;/strong&gt; listed extension is one iOS can type. Otherwise it is left off, and the content check that already runs after a pick tells a wrong file apart.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;IOS_TYPED_EXTENSIONS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ReadonlySet&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eml&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;zip&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fileInputAccept&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="nx"&gt;appleTouch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;appleTouch&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;every&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;IOS_TYPED_EXTENSIONS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;formats&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`.&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Detecting "Apple touch" needs one extra check: modern iPadOS often sends a Macintosh user agent, and gives itself away by having a touch screen (&lt;code&gt;maxTouchPoints &amp;gt; 1&lt;/code&gt;). Matching only &lt;code&gt;/iPhone|iPad|iPod/&lt;/code&gt; misses those iPads.&lt;/p&gt;

&lt;p&gt;A page that accepts only &lt;code&gt;.eml&lt;/code&gt; and &lt;code&gt;.zip&lt;/code&gt; still gets an &lt;code&gt;accept&lt;/code&gt; attribute. A page that mixes in &lt;code&gt;.pst&lt;/code&gt; or &lt;code&gt;.mbox&lt;/code&gt; does not. Tests pin both the helper and the homepage copy to that set, so a future format list cannot drift from the FAQ.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the homepage now says
&lt;/h2&gt;

&lt;p&gt;The hero line names an iPad next to the platforms that were already there. A new FAQ answers "Can I open a PST file on an iPad or iPhone?" with the practical path:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Yes, in Safari.&lt;/li&gt;
&lt;li&gt;Tap the drop area and choose the file in the Files app.&lt;/li&gt;
&lt;li&gt;The picker lists every file, because naming archive types by extension would grey most of them out.&lt;/li&gt;
&lt;li&gt;Whatever you choose is checked by its contents once picked.&lt;/li&gt;
&lt;li&gt;Large PST / OST / MBOX files are still read in pages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The same platform line went into &lt;code&gt;llms.txt&lt;/code&gt;, so answer engines that quote the site don't keep saying "Mac, PC, Chromebook, Android" and stop there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits I am not papering over
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The WebKit run is an engine-and-layout check. It is not a measurement of a specific iPad's free RAM, nor of every Files location (iCloud Drive, On My iPhone, shared folders).&lt;/li&gt;
&lt;li&gt;Leaving &lt;code&gt;accept&lt;/code&gt; off means the picker shows photos, PDFs and everything else. That is deliberate. The content sniffer rejects non-archives after the pick; the cost is one extra tap for someone who picks the wrong file.&lt;/li&gt;
&lt;li&gt;OLM, ZIP and MSG are still read whole into the tab. A phone runs out of memory for those sooner than a laptop. The iPad answer sticks to PST / OST / MBOX for the paging claim, which is what the code actually pages.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;On iOS, &lt;code&gt;accept&lt;/code&gt; is a MIME filter in disguise. Unknown extensions vanish; known ones become the only things you can tap.&lt;/li&gt;
&lt;li&gt;A mixed list is worse than no list, if your product's main format is in the unknown set.&lt;/li&gt;
&lt;li&gt;Omit &lt;code&gt;accept&lt;/code&gt; when you cannot name a typeable set, and validate by content after the pick.&lt;/li&gt;
&lt;li&gt;Detect iPadOS by touch points, not by the word "iPad" in the user agent alone.&lt;/li&gt;
&lt;li&gt;Don't claim a platform in the hero until the picker path on that platform has been walked.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need to open a PST on a tablet without Outlook, the homepage walkthrough is on &lt;a href="https://pst.aivismonitor.com/" rel="noopener noreferrer"&gt;Mailward&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt; The file stays on the device; Safari opens it locally.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>Putting Remote Email Images in a PDF From the Browser: CORS, Tracking Pixels, and Honest Failure Boxes</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Fri, 30 Oct 2026 02:58:56 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/putting-remote-email-images-in-a-pdf-from-the-browser-cors-tracking-pixels-and-honest-failure-1150</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/putting-remote-email-images-in-a-pdf-from-the-browser-cors-tracking-pixels-and-honest-failure-1150</guid>
      <description>&lt;p&gt;I added "save this email as a PDF" to a browser-based mail viewer. Everything runs locally: the message is parsed in a Web Worker and the PDF is built with &lt;code&gt;pdf-lib&lt;/code&gt;. Text, headers and attachments were easy. &lt;strong&gt;Images were the hard part.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pictures an email carries inside itself (&lt;code&gt;cid:&lt;/code&gt; references and &lt;code&gt;data:&lt;/code&gt; URIs) are simple: the bytes are already in the message. Pictures an email &lt;em&gt;links to&lt;/em&gt; (&lt;code&gt;&amp;lt;img src="https://…"&amp;gt;&lt;/code&gt;) are another story. My first version skipped them on purpose. Then a newsletter printed with blank gaps where its pictures should be, and it read like a bug. So I changed my mind, with constraints. Here is what those constraints are and why.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just &lt;code&gt;fetch()&lt;/code&gt; every &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;Two reasons, one about privacy and one about the platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Privacy.&lt;/strong&gt; Loading a remote image tells the sender's server that the mail was opened, and from where. That is how tracking pixels work. A tool that promises "your mail never leaves your device" must not turn into an open-tracker by accident. So the rules are strict:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No proxy. The browser requests the image straight from the host that serves it; the request never goes through my site.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;credentials: "omit"&lt;/code&gt; and &lt;code&gt;referrerPolicy: "no-referrer"&lt;/code&gt;, so no cookies and no page address are sent.&lt;/li&gt;
&lt;li&gt;Images that are clearly beacons are never requested: &lt;code&gt;width&lt;/code&gt; or &lt;code&gt;height&lt;/code&gt; of 2px or less, or &lt;code&gt;display:none&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Requests to private-network IP literals and the local machine are refused outright. A mail should not be able to make the converter poke at &lt;code&gt;169.254.169.254&lt;/code&gt; or &lt;code&gt;localhost&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The platform.&lt;/strong&gt; From a page, &lt;code&gt;fetch()&lt;/code&gt; of a cross-origin image is only &lt;em&gt;readable&lt;/em&gt; if the host sends &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;. An &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag can display such a picture, but code can't get its bytes to embed in a PDF without CORS permission.&lt;/p&gt;

&lt;h2&gt;
  
  
  CORS makes a dead host and a refusing host look the same
&lt;/h2&gt;

&lt;p&gt;When a CORS check fails, the browser gives your code a generic network error. You can't tell "this server is down" from "this server doesn't allow other sites to read its images" from "the picture moved". All look like a &lt;code&gt;TypeError&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;How common is it? I tried a set of popular image hosts on 2026-10-26. Roughly two thirds sent the header (GitHub, Substack, Amazon, LinkedIn, HubSpot, Klaviyo, Constant Contact, Shopify, Gravatar and googleusercontent did). Others did not: google.com/gstatic, SendGrid's S3 bucket, Campaign Monitor and apple.com. That is a small hand-picked sample, not a survey, but it is enough to say: &lt;strong&gt;a meaningful share of real newsletter images can't be embedded from a browser, and you can't fix that client-side.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So the design question became: what do you show in the PDF when a picture can't be had?&lt;/p&gt;

&lt;h2&gt;
  
  
  A box that says why, not a blank
&lt;/h2&gt;

&lt;p&gt;Instead of a gap, the PDF gets a grey box: "Picture not included", the alt text if there is any, and a reason. The reasons I can distinguish:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a network or CORS failure: "&lt;em&gt;host&lt;/em&gt; does not let other websites download its pictures, or is offline" (deliberately both, since the browser can't separate them);&lt;/li&gt;
&lt;li&gt;HTTP 404 or 410: "&lt;em&gt;host&lt;/em&gt; no longer has this picture";&lt;/li&gt;
&lt;li&gt;the reply is too large;&lt;/li&gt;
&lt;li&gt;the reply isn't an image;&lt;/li&gt;
&lt;li&gt;the format can't be put in a PDF;&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;cid:&lt;/code&gt; the message doesn't contain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two refinements keep the output tidy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Adjacent pictures that fail for the same reason share one box&lt;/strong&gt;, so a newsletter with twelve blocked banner slices doesn't become twelve grey rectangles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A failed picture with no size and no alt text is left out entirely.&lt;/strong&gt; That is almost certainly an open beacon, and a box for it would be noise.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The fetch rules in code
&lt;/h2&gt;

&lt;p&gt;The request options are the small part:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cors&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;omit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;referrerPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;no-referrer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="nx"&gt;_000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Around it sit the guardrails:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;http:&lt;/code&gt; and protocol-relative URLs are upgraded to &lt;code&gt;https:&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A 10-second timeout and a 10 MB cap. The cap is enforced while &lt;em&gt;streaming&lt;/em&gt; the body, so an oversized response is abandoned rather than buffered first.&lt;/li&gt;
&lt;li&gt;The reply must carry an image content type &lt;strong&gt;or&lt;/strong&gt; start with image magic bytes. A server can answer with something that isn't a picture, so the check doesn't rely on one signal alone.&lt;/li&gt;
&lt;li&gt;At most 100 pictures per message, six requests in flight at a time.&lt;/li&gt;
&lt;li&gt;A host that fails at the network level isn't asked again within that worker, so one dead host doesn't cost a timeout per picture.&lt;/li&gt;
&lt;li&gt;Pictures up to 512 KB are cached by address, since the same logo appears many times in a mailbox.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Order matters when you parallelise
&lt;/h2&gt;

&lt;p&gt;Exporting a folder of newsletters means many messages, each waiting on its own pictures. Rendering them one after another makes the slowest host stall everything. The folder export renders four messages at once. The output order stays that of the folder, which is the part that's easy to break: results are collected by index, not by completion time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing without trusting the network
&lt;/h2&gt;

&lt;p&gt;Unit tests exercise the rules without real servers: the address rules (&lt;code&gt;0.gravatar.com&lt;/code&gt; is allowed, &lt;code&gt;169.254.169.254&lt;/code&gt; is refused), the request options, each failure kind and its wording, the streamed size cap, one request per address and none after a host has failed, and that adjacent same-reason failures merge. For the real-browser behaviour, an end-to-end script in Chrome against a production build checks one CORS-friendly host (a GitHub avatar is drawn) and one that refuses (google.com's logo becomes a box with its reason), and asserts both requests went out without a referrer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell you if you build something similar
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Decide your privacy rule &lt;em&gt;first&lt;/em&gt;, then see which features survive it. "No proxy" is what forces the grey boxes.&lt;/li&gt;
&lt;li&gt;Don't pretend you know why a CORS failure happened. Say the two things it could be.&lt;/li&gt;
&lt;li&gt;Filter beacons before requesting, not after.&lt;/li&gt;
&lt;li&gt;Cap size while streaming, and verify the content, not just the header.&lt;/li&gt;
&lt;li&gt;Keep output order independent of completion order when you parallelise.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to see how it behaves on your own &lt;code&gt;.eml&lt;/code&gt; files, the page is the &lt;a href="https://pst.aivismonitor.com/eml-to-pdf" rel="noopener noreferrer"&gt;EML to PDF converter&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt; The message is processed in your browser; the only requests it makes are for fonts and emoji pictures from the site itself, and for the pictures the message itself links to, which go to their own servers.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>privacy</category>
      <category>pdf</category>
    </item>
    <item>
      <title>Why My PST Reader Showed 24 of 160 Items in an Outlook OST (and Raised No Error)</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Thu, 29 Oct 2026 02:16:07 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/why-my-pst-reader-showed-24-of-160-items-in-an-outlook-ost-and-raised-no-error-8ig</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/why-my-pst-reader-showed-24-of-160-items-in-an-outlook-ost-and-raised-no-error-8ig</guid>
      <description>&lt;p&gt;&lt;em&gt;A debugging story about row matrices, an 8 KB assumption, and a loop that stopped without telling anyone.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Here is the kind of bug I like least: nothing crashes, nothing logs, and the output looks plausible. A folder simply has fewer items than it should.&lt;/p&gt;

&lt;p&gt;I work on a browser-based viewer for Outlook mail files. It reads &lt;code&gt;.pst&lt;/code&gt; and &lt;code&gt;.ost&lt;/code&gt; files locally with a JavaScript library called &lt;code&gt;pst-extractor&lt;/code&gt; and a good deal of my own code around it. While testing with an Outlook 2013+ OST (the offline cache Outlook keeps for an Exchange or Microsoft 365 mailbox), I opened a calendar folder named "United States holidays". The folder tree said 160 items. The list showed &lt;strong&gt;24&lt;/strong&gt;. No exception, no warning.&lt;/p&gt;

&lt;p&gt;Here is what I found and how I fixed it. If you ever parse a PST or OST, one of these details may save you an afternoon.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two layouts that share a name
&lt;/h2&gt;

&lt;p&gt;Outlook's personal-folder files come in more than one layout. The old ANSI format, the Unicode PST, and the Outlook 2013+ files that use &lt;strong&gt;4 KB pages&lt;/strong&gt; (version number 36 in the header, which is what my test file reports) are all "PST-family" files, but they don't store data blocks the same way.&lt;/p&gt;

&lt;p&gt;Folder contents in these files are stored in a &lt;strong&gt;Table Context&lt;/strong&gt;, which is, roughly, a table with a "row matrix": fixed-size rows laid out one after another. Each row starts with a 4-byte row ID. A separate row index maps row IDs to row numbers.&lt;/p&gt;

&lt;p&gt;To read row &lt;code&gt;r&lt;/code&gt;, a parser needs the byte offset of that row. The library I use computes it the way the Unicode PST layout dictates: data blocks of 8,176 bytes, with padding at the end of each block, so&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;offset(r) = floor(r / rowsPerBlock) × 8176 + (r mod rowsPerBlock) × rowSize
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is correct for Unicode PSTs. It is wrong for a 4K OST.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the 4K OST actually contains
&lt;/h2&gt;

&lt;p&gt;In my test file, the contents table of the 160-item calendar folder is &lt;strong&gt;a single deflate-compressed block of 54,240 bytes&lt;/strong&gt;. That is exactly 160 rows × 339 bytes per row, with no padding. The data blocks in this layout are larger than 8 KB.&lt;/p&gt;

&lt;p&gt;Now apply the 8 KB arithmetic. Row 24 should start at byte 8,136 (24 × 339), but the formula treats a block as ending at 8,176 and reads row 24 from byte 8,176 instead. It finds whatever bytes are there and reads a garbage row ID.&lt;/p&gt;

&lt;p&gt;The folder cursor (the code that pages through items) treats a row ID that doesn't make sense as the end of the table. It stops. No error. The library reported &lt;code&gt;rowCount&lt;/code&gt; as 159, and the list showed 24.&lt;/p&gt;

&lt;p&gt;That's the whole bug: one layout assumption, applied to a file format that breaks it, and a loop that fails quietly instead of loudly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: stop computing offsets, find them
&lt;/h2&gt;

&lt;p&gt;I didn't want to rewrite the whole reader. The fix patches the table class for the 4K layout only, and leaves Unicode and ANSI files on the library's original code path.&lt;/p&gt;

&lt;p&gt;The idea: &lt;strong&gt;don't compute where row &lt;code&gt;r&lt;/code&gt; is, locate it, and verify.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Row 0 starts at offset 0.&lt;/li&gt;
&lt;li&gt;Row &lt;code&gt;r&lt;/code&gt; starts where row &lt;code&gt;r-1&lt;/code&gt; ended.&lt;/li&gt;
&lt;li&gt;Check it: read the 4-byte row ID at that offset, look it up in the table's row index, and confirm that it maps to row number &lt;code&gt;r&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If it doesn't match, look further, within the next &lt;code&gt;rowSize - 1&lt;/code&gt; bytes. This covers the case where a row matrix spans several blocks and the writer left padding at the end of a block (the libpff documentation describes that padding).&lt;/li&gt;
&lt;li&gt;If the row still can't be found, &lt;strong&gt;end the table&lt;/strong&gt; rather than return a garbage row.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;locateRows&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;readRowId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;rowSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;rowIndexById&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ReadonlyMap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rowSize&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;rowIndexById&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;found&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;at&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;at&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;rowSize&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;rowSize&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rowIndexById&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;readRowId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;found&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;found&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;found&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;at&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;found&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;rowSize&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The check against the row index is the important part. It turns "I assume this offset is right" into "this offset is right, because the row at it says it is row &lt;code&gt;r&lt;/code&gt;." A wrong guess ends the table instead of producing wrong data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reusing the library's own row parsing
&lt;/h2&gt;

&lt;p&gt;Locating rows is half of it. Decoding a row is still the library's job, and I wanted to keep it. The library reads row &lt;code&gt;r&lt;/code&gt; at &lt;code&gt;r × rowSize&lt;/code&gt; from the start of a node. So for each row, I hand it a node &lt;strong&gt;shifted&lt;/strong&gt; by the difference between where the row really is and where the library will look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shift&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;offsets&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TCI_bm&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rowNodeInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NodeInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startOffset&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;endOffset&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pstNodeInputStream&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;originalGetItems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the duration of the call the library's block size is set to a huge value, so its own padding step never kicks in, and the original node is restored in a &lt;code&gt;finally&lt;/code&gt;. The &lt;code&gt;rowCount&lt;/code&gt; getter is overridden the same way for 4K files. It is a monkey patch, but a contained one: it only applies when the file's type is the 4K one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "end of table" signal
&lt;/h2&gt;

&lt;p&gt;The library's folder cursor stops when it reads a row carrying a particular sentinel. When my locator has no more rows, the patched &lt;code&gt;getItems&lt;/code&gt; returns exactly that sentinel (a fake row with item index −1), so the cursor ends cleanly instead of reading past what was located.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing, and what I could not test
&lt;/h2&gt;

&lt;p&gt;The regression test uses the library's own test OST (MIT-licensed test data, gzipped in my fixtures). It asserts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the header is the 4K layout (&lt;code&gt;!BDN&lt;/code&gt; magic, version 36);&lt;/li&gt;
&lt;li&gt;the "United States holidays" folder lists all &lt;strong&gt;160&lt;/strong&gt; items, and row 24, the first one the 8 KB arithmetic misplaced, matches the full listing;&lt;/li&gt;
&lt;li&gt;paging works at the end of the table (asking for 50 items from row 150 returns 10);&lt;/li&gt;
&lt;li&gt;every message folder in that file lists the count the folder tree shows, and the result is the same through a paged reader with a small cache;&lt;/li&gt;
&lt;li&gt;a regular Unicode PST still lists the same 71 messages as before, so the patch doesn't touch it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One limit I want to be upfront about: I did not have a real 4K OST whose row matrix spans multiple blocks. The "look past the block's tail padding" path is covered only by tests on &lt;strong&gt;synthetic&lt;/strong&gt; data, where I build matrices with padding between blocks and check that the offsets come out right. The real-file case I verified is the single-block one. If you have a multi-block 4K sample, that's the case I'd most like to see.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A "file format" often means several layouts. Check which one your library's arithmetic was written for.&lt;/li&gt;
&lt;li&gt;Silent truncation is worse than a crash. If a loop ends early, cross-check it against a count you already have (here, the folder's 160 versus the 24 listed).&lt;/li&gt;
&lt;li&gt;Prefer &lt;strong&gt;locate and verify&lt;/strong&gt; over &lt;strong&gt;compute and trust&lt;/strong&gt; when a format has self-describing indexes.&lt;/li&gt;
&lt;li&gt;Keep a patch narrowly scoped (one layout), and leave the working path alone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to try it on your own file, the tool's &lt;a href="https://pst.aivismonitor.com/ost-viewer" rel="noopener noreferrer"&gt;OST viewer page&lt;/a&gt; is where this lives. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt; It reads the file in your browser without uploading it.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>debugging</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Splitting an Audio Project at Label Marks, the Way Audacity Does It (and Batch-Exporting Many Projects)</title>
      <dc:creator>王磊</dc:creator>
      <pubDate>Wed, 28 Oct 2026 03:30:54 +0000</pubDate>
      <link>https://dev.to/_172c9b2760d6c5bc1e8966/splitting-an-audio-project-at-label-marks-the-way-audacity-does-it-and-batch-exporting-many-lk4</link>
      <guid>https://dev.to/_172c9b2760d6c5bc1e8966/splitting-an-audio-project-at-label-marks-the-way-audacity-does-it-and-batch-exporting-many-lk4</guid>
      <description>&lt;p&gt;If you edit podcasts or long recordings in Audacity, you probably use label tracks: little text marks on the timeline ("Intro", "Interview", "Outro"). Audacity can split a project into one file per label (&lt;em&gt;Export Multiple → Split files based on Labels&lt;/em&gt;). I recently added the same thing to a browser-based &lt;code&gt;.aup3&lt;/code&gt;/&lt;code&gt;.aup4&lt;/code&gt; tool, plus a batch mode for several projects at once. Reproducing the rule exactly took more care than I expected, so here is how it works and what tripped me up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where labels live
&lt;/h2&gt;

&lt;p&gt;A label track is stored in the project document as &lt;code&gt;&amp;lt;labeltrack&amp;gt;&lt;/code&gt; containing &lt;code&gt;&amp;lt;label t="…" t1="…" title="…"/&amp;gt;&lt;/code&gt; elements. &lt;code&gt;t&lt;/code&gt; is the start in seconds and &lt;code&gt;t1&lt;/code&gt; the end. I checked the writer (&lt;code&gt;LabelTrack::WriteXML&lt;/code&gt;) in Audacity 3.7.9 and 4.0.0 and the same names show up in &lt;code&gt;.aup3&lt;/code&gt;, &lt;code&gt;.aup4&lt;/code&gt; and the old XML-based 1.x/2.x &lt;code&gt;.aup&lt;/code&gt;, so one reader covers all three. Audacity 4.0 only adds an &lt;code&gt;isSelected&lt;/code&gt; attribute.&lt;/p&gt;

&lt;p&gt;Two label kinds share this structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;strong&gt;region label&lt;/strong&gt; has &lt;code&gt;t1 &amp;gt; t&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;a &lt;strong&gt;point label&lt;/strong&gt; has &lt;code&gt;t1 == t&lt;/code&gt; (or a missing or backwards &lt;code&gt;t1&lt;/code&gt;, which I treat as a point).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That distinction drives the whole split rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  The split rule
&lt;/h2&gt;

&lt;p&gt;I followed what Audacity's export dialog code does (&lt;code&gt;ExportAudioDialog::UpdateLabelExportSettings&lt;/code&gt;, read at the 4.0.0 tag):&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every label starts a file.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;region&lt;/strong&gt; label ends its file at the region's own end.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;point&lt;/strong&gt; label ends its file at the &lt;em&gt;next label's start&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;last&lt;/strong&gt; point label runs to the end of the audio.&lt;/li&gt;
&lt;li&gt;Audio &lt;em&gt;before&lt;/em&gt; the first label becomes a file only if you ask for it ("Include audio before first label", off by default), and it is named after the project.&lt;/li&gt;
&lt;li&gt;An empty title becomes &lt;code&gt;untitled&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Files are numbered &lt;code&gt;01-Title&lt;/code&gt;, &lt;code&gt;02-Title&lt;/code&gt;, … so they sort.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The core is small:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sorted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isPoint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;isPoint&lt;/span&gt;
    &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
      &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;
      &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;number&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;untitled&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;end&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that a region label's end is &lt;em&gt;not&lt;/em&gt; clipped to the next label. Overlapping regions produce overlapping files, which is what Audacity's rule does too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pitfalls
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Segments need clamping.&lt;/strong&gt; Label times come from a document a user may have edited, shortened, or hand-crafted. I clamp both ends into &lt;code&gt;[0, duration]&lt;/code&gt; and drop any segment shorter than one sample (&lt;code&gt;1/48000&lt;/code&gt; s). Otherwise you export empty files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;File names are a mess.&lt;/strong&gt; Titles contain &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;:&lt;/code&gt;, &lt;code&gt;?&lt;/code&gt;, quotes and control characters, and two labels can have the same title. I replace the characters file systems reject with &lt;code&gt;_&lt;/code&gt; (similar to what Audacity's &lt;code&gt;Internat::SanitiseFilename&lt;/code&gt; does), collapse whitespace, cap at 120 characters, and de-duplicate case-insensitively, since macOS and Windows treat &lt;code&gt;Intro&lt;/code&gt; and &lt;code&gt;intro&lt;/code&gt; as the same file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;used&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;base&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; (&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;)`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;used&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Audacity only looks at the first label track.&lt;/strong&gt; A project can have several. Audacity's split always uses the first. I let the user pick which one, since a project with one label track for chapters and another for edit notes is common.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Each piece must be exactly its span of the mix.&lt;/strong&gt; I render each file as a window of the whole mixed-down audio, rather than re-mixing each piece separately. A test checks that a split file is exactly its span of the mix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Giving the pieces names players can read
&lt;/h2&gt;

&lt;p&gt;Split MP3s carry a title and track number, written as an ID3v2.3 tag in front of the encoded stream. I chose v2.3 over v2.4 for its wider player support. The consequence is that v2.3 has no UTF-8, so text frames are UTF-16 with a byte-order mark. Frame sizes are plain big-endian in 2.3, and only the tag header's size is "syncsafe" (7 bits per byte) — an easy detail to get backwards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Batch: many projects, one worker
&lt;/h2&gt;

&lt;p&gt;If you drop two or more &lt;code&gt;.aup3&lt;/code&gt;/&lt;code&gt;.aup4&lt;/code&gt; files (each with its own &lt;code&gt;-wal&lt;/code&gt; if it has one) or a folder of them, the page lists them instead of opening one. The design decisions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One project in memory at a time.&lt;/strong&gt; The batch opens and exports projects sequentially in the same Web Worker. Opening them in parallel would multiply memory use, and projects can be large.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One failure never stops the batch.&lt;/strong&gt; A project whose document doesn't decode is skipped and named in the report rather than aborting the run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Everything goes into one ZIP&lt;/strong&gt;, built in the browser, with a &lt;code&gt;batch report.txt&lt;/code&gt;. Per project it lists the files produced, any unreadable blocks, effects that weren't rendered, and what was skipped or failed and why.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optionally split each project at its labels&lt;/strong&gt;, with a folder per project and each project's label file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Deciding what a drop &lt;em&gt;is&lt;/em&gt; lives in a pure planning function that looks at the dropped file names and returns a kind (single project, batch, and so on), so it can be unit-tested without a browser. Recovery and downgrade pages keep one project at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is free and what isn't
&lt;/h2&gt;

&lt;p&gt;For transparency: reading labels and exporting Audacity's own label text file (start, end, title, tab-separated, six decimals — the format &lt;em&gt;File → Import → Labels&lt;/em&gt; reads back) or "m:ss Title" timestamps is free. Splitting at labels, the chaptered MP3 and batch export are paid features in the tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;The unit tests pin the document reading, the split rule, both text formats, the ID3 bytes and the free/paid split. The fixtures are two existing test projects with label tracks added; the audio is untouched. An end-to-end script runs the feature with real pointer events on desktop and phone viewports. Its first run caught label names overlapping in the phone-width timeline lane, so a point label's text now gets only the room up to the next label.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;If you want to see this without installing Audacity, the splitting feature is described at &lt;a href="https://aup4.aivismonitor.com/split-audacity-project-by-labels" rel="noopener noreferrer"&gt;Waveward's split-by-labels page&lt;/a&gt;. &lt;strong&gt;Disclosure: I built it.&lt;/strong&gt; Everything runs in your browser, and projects are not uploaded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Copy the reference implementation's rule, including its odd corners, and note which version you read.&lt;/li&gt;
&lt;li&gt;Treat region and point labels differently; the next label's start is the only end a point label has.&lt;/li&gt;
&lt;li&gt;Clamp, drop empty segments, sanitize and de-duplicate names.&lt;/li&gt;
&lt;li&gt;Batch work: sequential, isolated failures, and a report that says what was skipped.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>audio</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
