Last active
February 20, 2022 19:38
-
-
Save JackZielke/703f686bd7e5402a431d34ec933c9c5f to your computer and use it in GitHub Desktop.
Convert email address into html codes @
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
#!/bin/bash | |
if [ $# -ne 1 ] | |
then | |
echo | |
echo "usage: $0 <email@address>" | |
echo | |
echo | |
exit 1 | |
fi | |
echo -n "mailto:" | |
COUNT=1 | |
CHAR=`echo $1|cut -c 1` | |
while [ "$CHAR" != "" ] | |
do | |
DEC=`echo $CHAR|perl -e 'print ord <STDIN>'` | |
echo -n "&#${DEC};" | |
COUNT=$[COUNT+1] | |
CHAR=`echo $1|cut -c $COUNT` | |
done | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know if this is the approach I would take if I were doing this now, but it seemed like a good idea in 2004. I tested it and it still works. I don't know if they have code to prevent accidentally putting email addresses in comments, but let's see what happens.
It just converts all of the text to HTML Codes and puts a mailto: in the front. I don't know if email address scapers decode these now or not, but it used to work really well to keep the spam down and still have a working email link.