Last active
June 10, 2016 06:36
-
-
Save lutzissler/a9330b4fb8c087ba0a35997ab2cb7db5 to your computer and use it in GitHub Desktop.
ROT13 encode all mailto: links in the HTML.
This file contains 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
function encode_mailto($s) { | |
return preg_replace_callback('#<a href="mailto:(.+?)">(.*?)</a>#', function ($matches) { | |
return '<a href="#" onclick="location.href=\'' . str_rot13('mailto:' . $matches[1]) . '\'.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<=\'Z\'?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});return false">' . str_replace('@', ' [​at​] ', $matches[2]) . '</a>'; | |
}, $s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment