Skip to content

Instantly share code, notes, and snippets.

@ernstki
Last active December 7, 2025 12:17
Show Gist options
  • Select an option

  • Save ernstki/c1408d1f938276f36b77047a4835a3de to your computer and use it in GitHub Desktop.

Select an option

Save ernstki/c1408d1f938276f36b77047a4835a3de to your computer and use it in GitHub Desktop.
Convert Microsoft Outlook "safelinks" URL back into human-readable URLs
#!/usr/bin/env perl
use v5.24;
use utf8;
use strict;
use warnings;
# ref: https://stackoverflow.com/a/47946606
use open qw(:std :utf8);
use lib '.';
use Unsafelinks;
my $url = 'https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fresearch.uc.edu&data=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&sdata=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&reserved=0';
say unsafeurl($url);
# *only* prints the URL
say unsafeurl "Visit the Office of Research at: $url";
# preserves other inline text
say unsafe "Visit the Office of Research at $url!";
say unsafe "Visit the Office of Research ($url) today.";
say unsafe "Visit the Office of Research at $url--today!";
say unsafe "Visit the Office of Research at $url… today!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment