tmux: Do not delay esc
[shutils.git] / dotfiles / mutt / scripts / ciscoclean
1 #!/bin/sh
2
3 set -e
4
5 PROG="$0"
6
7 ciscowipe() {
8 # Remove secure-web.cisco.com prefix
9 sed -E "s!https?://secure-web.cisco.com/[^/ ]*/!!g" |
10 # URL decode
11 # Decodes all URL escape sequences
12 #sed -e 's!+! !g;s!%\([0-9A-Fa-f]\{2\}\)!\\x\1!g' | xargs -0 printf "%b"
13 # Decodes only some escape sequences, but leaves others, like spacs,
14 # as is.
15 sed 's!%3A!:!g;s!%2F!/!g;s!%3F!?!g;s!%3D!=!g;s!%26!\&!g'
16 }
17
18 usage() {
19 cat<<EOF
20 Mr. Clean for Cisco's mail snakeoil. It restores the original URL from the URL
21 generated by Cisco's mail security software.
22
23 Usage:
24 $PROG -h
25 $PROG [FILE]...
26
27 If no filename is given then stdin is processed. Otherwise all files passed are
28 processed.
29 EOF
30 }
31
32 if [ "$#" -eq 0 ]; then
33 ciscowipe
34 else
35 for f in "$@"; do
36 if [ "$f" = "-h" ]; then
37 usage
38 exit
39 fi
40 cat "$f" | ciscowipe
41 done
42 fi