Rev 1342 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
561 | gleu | 1 | #!/bin/bash |
2 | |||
3 | # obfuscate.sh |
||
4 | # obfuscate email addresses in XML/HTML |
||
5 | # Script written (and slight perl modification) by Archaic <archaic AT linuxfromscratch D0T org> |
||
598 | gleu | 6 | # Modified from "sed -i" to old style "sed -e" by Manuel Canales <manuel AT linuxfromscratch D0T org> |
7 | # to prevent hangs on very long files, like nonckunked books. |
||
561 | gleu | 8 | # Original Perl expression by Anderson Lizardo <lizardo AT linuxfromscratch D0T org> |
9 | # Released under the GNU General Public License |
||
10 | # |
||
11 | # This script currently only seeks out mailto: addresses. If those same |
||
12 | # addresses also appear in plaintext, we need to obfuscate those as well. |
||
13 | # |
||
14 | # This script was made for a very specific purpose so I was a bit lazy in |
||
15 | # writing the regex's. |
||
16 | # |
||
17 | # Please send comments, enhancements, etc. to the above address |
||
18 | |||
19 | #set -e # Bail on all errors |
||
20 | |||
21 | # First, ensure that we are given a file to process |
||
22 | # if [ $# -lt 1 ]; then |
||
23 | # echo -e "\nYou must provide an input file." |
||
24 | # exit 1 |
||
25 | # fi |
||
26 | |||
27 | # Nothing like a backup plan! |
||
28 | #cp "$1" "$1".bak |
||
29 | |||
598 | gleu | 30 | for i in `grep -o '"mailto:.*@.*"' ${1} |sed -e 's|^"mailto:||' -e 's|"$||'`; do |
561 | gleu | 31 | link=`echo $i | perl -pe 's/[^\n]/"\\\&#".ord($&)."\;"/ge'` |
32 | plaintext=`echo $i | sed -e 's|@| AT |' -e 's|\.| D0T |g'` |
||
602 | texou | 33 | cp ${1}{,.tmp} |
598 | gleu | 34 | sed -e "s|mailto:$i|mailto:$link|" \ |
35 | -e "s|$i|$plaintext|" ${1}.tmp > ${1} |
||
36 | rm ${1}.tmp |
||
561 | gleu | 37 | done |
598 | gleu | 38 | #rm $FILE.tmp |
561 | gleu | 39 | #exit 0 |