I hate surveillance. I hate non-standard stuff. I hate stupid choices.
That's one of the many reasons why I hate Microsoft and its many
I must interact with an Exchange email server, because a couple of years
ago my employer decided to outsource all institutional emails to Office
365 (for free). I am obviously using the "service" exclusively via IMAP
and POP, but it still sucks a lot. A couple of weeks ago, the email
server started "mangling" the links contained in incoming emails,
replacing each URL with a link to a Microsoft dis-service, namely
safelinks.protection.outlook.com. This means when you click on a link
contained in one email you have received, you are redirected to a M$
proxy server, which in turns "checks the link" for security risks, and,
if no risk is detected, will forward you to the actual destination.
No need to say that this is *WRONG* for one-thousand different reasons,
but I spare you the swearing.
I needed a quick solution to this unbearable madness. Luckily, the
original link is still present (url-encoded) in the "safe" link, so I
put together a little shell script that "sanitises" such URLs:
NEWURL=$(echo "$URL" | \
tr -d '\n' | \
sed -E 's:.*safelinks\.protection\.outlook\.com.*url=([^&]*).*$:\1:g;s:\+: :g;s:%:\\x:g' | \
xargs -0 printf "%b " )
echo "$NEWURL"| xclip
You just select the URL to sanitise with your mouse, and then you click
a keystroke associated to that script, and the primary selection of your
current X11 display will be set to the sanitised URL. For instance, I
did this using `sxhkd`, and binding the script to CTRL+SHIFT+U. So I can
select a URL in mutt, press CTRL+SHIFT+u, and then paste the sanitised
primary selection wherever I like (e.g., in `surf`, using CTRL+P).
In the script, `tr(1)` removes newlines, `sed` takes the safe link, gets
the original one, and de-url-encodes it by replacing each '%' with a
'\x' and giving the result as input to `printf`. Finally, `xclip` is
used to get the current primary selection and to set it to the sanitised
Unix sanity - Surveillance Madness: 1 - 0