source: obfuscate.sh@ 688f954

Last change on this file since 688f954 was fbb5e45, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added obfuscate.sh to test it in production mode.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@6568 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 1.1 KB
Line 
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>
6# Original Perl expression by Anderson Lizardo <lizardo AT linuxfromscratch D0T org>
7# Released under the GNU General Public License
8#
9# This script currently only seeks out mailto: addresses. If those same
10# addresses also appear in plaintext, we need to obfuscate those as well.
11#
12# This script was made for a very specific purpose so I was a bit lazy in
13# writing the regex's.
14#
15# Please send comments, enhancements, etc. to the above address
16
17#set -e # Bail on all errors
18
19# First, ensure that we are given a file to process
20# if [ $# -lt 1 ]; then
21# echo -e "\nYou must provide an input file."
22# exit 1
23# fi
24
25# Nothing like a backup plan!
26#cp "$1" "$1".bak
27
28for i in `grep -o '"mailto:.*@.*"' "$1" |sed -e 's|^"mailto:||' -e 's|"$||'`; do
29 link=`echo $i | perl -pe 's/[^\n]/"\\\&#".ord($&)."\;"/ge'`
30 plaintext=`echo $i | sed -e 's|@| AT |' -e 's|\.| D0T |g'`
31 sed -i "s|mailto:$i|mailto:$link|" "$1"
32 sed -i "s|$i|$plaintext|" "$1"
33done
34
35#exit 0
Note: See TracBrowser for help on using the repository browser.