{"id":47896,"date":"2025-05-29T17:26:52","date_gmt":"2025-05-29T21:26:52","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=47896"},"modified":"2025-06-03T16:59:31","modified_gmt":"2025-06-03T20:59:31","slug":"spamsieve-3-1-3","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2025\/05\/29\/spamsieve-3-1-3\/","title":{"rendered":"SpamSieve 3.1.3"},"content":{"rendered":"<p><a href=\"https:\/\/c-command.com\/blog\/2025\/05\/29\/spamsieve-3-1-3\/\">SpamSieve 3.1.3<\/a> improves the filtering accuracy of my Mac e-mail spam filter. It works with the new <a href=\"https:\/\/mailmaven.app\">MailMaven<\/a> e-mail client and includes enhancements for notification and server junk filters, along with various other fixes and improvements.<\/p>\n\n<p>Some interesting issues were:<\/p>\n\n<ul>\n<li><p>The Mail extension API is only supposed to send the extension messages to filter &ldquo;when it downloads a message,&rdquo; but some customers were seeing it try to filter <em>draft<\/em> messages that were created locally on the Mac. Why would the user ever want those to be touched (FB17547044)?<\/p><\/li>\n\n<li><p>One customer also reported that Mail sometimes doesn&rsquo;t send the extension the correct message data. The headers are <em>modified<\/em> and <em>reordered<\/em> so that if SpamSieve sees the same message again later it thinks it&rsquo;s a different message. There&rsquo;s an experimental workaround for this, but it&rsquo;s not clear why it&rsquo;s only happening for this one user. There were several similar bugs in previous versions of Mail (where it would simply <em>omit<\/em> some of the message data when communicating with the extension), but those were much more widespread and easy to reproduce.<\/p><\/li>\n\n<li><p>A longstanding problem, which we&rsquo;ve <a href=\"https:\/\/c-command.com\/spamsieve\/help\/check-inboxes-for-new-m\">worked around<\/a>, is that sometimes Mail stops sending new messages to the extension to be filtered. I think there are multiple causes for this, but one that&rsquo;s 100% reproducible is that it <em>never<\/em> works if the app owning the extension is launched after Mail itself (FB17368083).<\/p><\/li>\n\n<li><p>SpamSieve uses <a href=\"https:\/\/github.com\/stephencelis\/SQLite.swift\">SQLite.swift<\/a> to read Mail&rsquo;s database, and in rare cases it was crashing when the database wasn&rsquo;t as expected. This is because there are several places where SQLite.swift is type-safe at compile time but not at runtime. It&rsquo;s <a href=\"https:\/\/github.com\/stephencelis\/SQLite.swift\/blob\/master\/Documentation\/Index.md#iterating-and-accessing-values\">not safe to subscript<\/a> a <code>Row<\/code> from the database, because if the column isn&rsquo;t present or is unexpectedly <code>NULL<\/code> it will force unwrap and crash. There&rsquo;s a corresponding <code>get() throws<\/code> API that looks like it will be better because it reports errors, but to my surprise that <em>also<\/em> has some internal force unwraps. I had thought that by telling it that a column was a <code>URL?<\/code> it would give me a <code>nil<\/code> if the string was not a valid URL. But, actually, it does <code>URL(string: stringValue)!<\/code> (and similarly for <code>Date<\/code> and <code>UUID<\/code>). I think the only safe thing to do is to read types that SQLite can natively query and convert them at the application level.<\/p><\/li>\n\n<li><p>In some cases, Core Data was spending a lot of time repeatedly reading the store&rsquo;s options dictionary, and this was bridged from Swift so it got bogged down in <code>swift_dynamicCast()<\/code>. This all goes away if I give it a real <code>NSDictionary<\/code>.<\/p><\/li>\n\n<li><p>This version includes the previously mentioned <a href=\"https:\/\/mjtsai.com\/blog\/2024\/10\/02\/local-network-privacy-on-sequoia#local-network-privacy-on-sequoia-update-2025-05-15\">local network privacy fix<\/a>.<\/p><\/li>\n\n<\/ul>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2025\/05\/05\/mailmaven-public-beta\/\">MailMaven Public Beta<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2025\/04\/01\/spamsieve-3-1-2\/\">SpamSieve 3.1.2<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2024\/10\/02\/local-network-privacy-on-sequoia\/\">Local Network Privacy on Sequoia<\/a><\/li>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2023\/11\/17\/mail-extension-postmortem\/\">Mail Extension Postmortem<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>SpamSieve 3.1.3 improves the filtering accuracy of my Mac e-mail spam filter. It works with the new MailMaven e-mail client and includes enhancements for notification and server junk filters, along with various other fixes and improvements. Some interesting issues were: The Mail extension API is only supposed to send the extension messages to filter &ldquo;when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2025-05-29T21:26:55Z","apple_news_api_id":"04eb3ee9-6e86-4874-8878-0577bb956367","apple_news_api_modified_at":"2025-05-29T21:26:55Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/ABOs-6W6GSHSIeAV3u5VjZw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[126,109,30,32,2598,2409,2408,138,71,372,425,901],"class_list":["post-47896","post","type-post","status-publish","format-standard","hentry","category-technology","tag-applemail","tag-coredata","tag-mac","tag-macapp","tag-macos-15-sequoia","tag-mail-app-extensions","tag-mailmaven","tag-optimization","tag-programming","tag-spamsieve","tag-sqlite","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=47896"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47896\/revisions"}],"predecessor-version":[{"id":47897,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/47896\/revisions\/47897"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=47896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=47896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=47896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}