<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">Hi Benny and friends,</p>

<p dir="auto">I’ve been thinking about whether there’d be an easy way for you to add conditional domain-based image loading, without doing a bunch of UI work for a feature that (admittedly) has limited appeal.</p>

<p dir="auto">How about this:</p>

<ol>
<li value="1">define a new advanced preference: <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">defaults write com.freron.MailMate MmExternalUriApprover -string /path/to/uriapprover</code></li>
<li value="2">If this is set, MailMate would run this program when displaying an HTML email. It would send the program each image URL on stdin, and expect to get back the strings <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">allow</code> or <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">deny</code>.</li>
<li value="3">MailMate would use this information to decide whether to display each external image.</li>
</ol>

<p dir="auto">I would write my own <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">uriapprover</code> script. A simple version might look like this:</p>

<pre style="background-color:#F7F7F7; border-radius:5px 5px 5px 5px; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px; color:black" bgcolor="#F7F7F7"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0" bgcolor="#F7F7F7"><span style="color: #888888">#!/usr/bin/env perl</span>

<span style="color: #008800; font-weight: bold">use</span> <span style="color: #0e84b5; font-weight: bold">Modern::</span>Perl;
<span style="color: #008800; font-weight: bold">use</span> <span style="color: #0e84b5; font-weight: bold">Text::</span>Glob <span style="background-color: #fff0f0">'glob_to_regex_string'</span>;
<span style="color: #008800; font-weight: bold">use</span> URI;

<span style="color: #008800; font-weight: bold">my</span> <span style="color: #996633">@allowed</span> <span style="color: #333333">=</span> <span style="color: #DD2200; background-color: #fff0f0">qw(</span>
<span style="color: #DD2200; background-color: #fff0f0">    *.slack.com</span>
<span style="color: #DD2200; background-color: #fff0f0">    *.amazon.com</span>
<span style="color: #DD2200; background-color: #fff0f0">    *.postmark.com</span>
<span style="color: #DD2200; background-color: #fff0f0">)</span>;

<span style="color: #008800; font-weight: bold">my</span> <span style="color: #996633">$allowed</span> <span style="color: #333333">=</span> <span style="color: #007020">join</span>(<span style="background-color: #fff0f0">'|'</span>, <span style="color: #007020">map</span>(glob_to_regex_string(<span style="color: #996633">$_</span>), <span style="color: #996633">@allowed</span>));
<span style="color: #008800; font-weight: bold">sub </span><span style="color: #0066BB; font-weight: bold">allowed</span> { <span style="color: #007020">eval</span> { <span style="color: #008800; font-weight: bold">return</span> URI<span style="color: #333333">-></span><span style="color: #008800; font-weight: bold">new</span>(<span style="color: #996633">$_</span>)<span style="color: #333333">-></span>host <span style="color: #333333">=~</span> <span style="color: #000000; background-color: #fff0ff">m/($allowed)/o</span> } }
<span style="color: #008800; font-weight: bold">while</span> (<span style="color: #333333"><></span>) { say allowed(<span style="color: #996633">$_</span>) ? <span style="background-color: #fff0f0">"allow"</span> : <span style="background-color: #fff0f0">"deny"</span> }
</code></pre>



<p dir="auto">Everyone else could ignore this feature.</p>

<p dir="auto">What do you think?<br>
-sam</p>
</div>
</div>
</body>
</html>