Created
January 22, 2020 03:57
-
-
Save baldwicc/3623b8eea96eb0cbbe41b1f51aeca21f to your computer and use it in GitHub Desktop.
Proofpoint urldefense.com URL Decoder (v3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Decodes a Proofpoint urldefense.com (v3 format) | |
* Reference: https://help.proofpoint.com/@api/deki/files/177/URLDefenseDecode.py?revision=2 | |
* @param {String} link typical format: 'https://urldefense.com/v3/__<encoded url>__;<replacement characters>!!<assorted click tracking goodness>$' | |
*/ | |
function decodeUrlDefensev3(link) { | |
var matches = link.match(new RegExp('v3/__(.+?)__;(.*?)!')) | |
// love me a mutable array | |
var decode_pile = Array.from(matches[1]); | |
var chars_pile = Array.from(atob(matches[2])).reverse(); | |
for (var match of encoded_url.matchAll(/\*/g)) { | |
decode_pile[match.index] = encoded_chars.pop() | |
} | |
return decode_pile.join('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
encoded_url
is not defined... should belink
...