blob: a2766ca6e47452627d874eb8793befdef17f3699 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/bin/bash
decode() {
sed '
:a
s/=?\(ISO-8859-15\?\|windows-1252\|UTF-8\)?Q?\([^=_]*\)?=/\2/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)_/\1 /
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=E4/\1ä/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=E9/\1é/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=F6/\1ö/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=F8/\1ř/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=FC/\1ü/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=FD/\1ý/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=DF/\1ß/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=22/\1"/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=2C/\1,/
s/\(=?\(ISO-8859-15\?\|windows-1252\)?Q?[^=]*\)=2E/\1,/
s/\(=?UTF-8?Q?[^=]*\)_/\1 /
s/\(=?UTF-8?Q?[^=]*\)=c3=a4/\1ä/
s/\(=?UTF-8?Q?[^=]*\)=c3=b6/\1ö/
s/\(=?UTF-8?Q?[^=]*\)=c3=bc/\1ü/
s/\(=?UTF-8?Q?[^=]*\)=c3=9f/\1ß/
s/\(=?UTF-8?Q?[^=]*\)=c3=98/\1ø/
s/\(=?UTF-8?Q?[^=]*\)=22/\1"/
s/\(=?UTF-8?Q?[^=]*\)=2c/\1,/
ta
'
}
sed '
:a
N
s/\n\s\+/ /
ta
P
D
' \
| sed -n '
s@^\(bcc\|Bcc\|BCC\|cc\|Cc\|CC\|To\|Reply-To\): @@
T
:b
s@^\(\([^"]*"[^"]*"\)*[^"]*\),\s\+@\1\n@g
tb
p
' \
| sed '
s#^\(.*\S\)\s*<\(\S\+@\S\+\)>$#\2 \1#
t
/^\S\+@\S\+$/!d
' \
| sort -uf \
| while read -r email comment; do
printf '%s %s %s\n' \
"${#comment}" \
"$(echo "$comment" | base64 -w0)" \
"${email}"
done \
| sort -k3,3 -k1nr,1 \
| uniq -f2 \
| while read -r _ comment email; do
printf '\t%s\t%s\n' \
"$(
printf '%s\n' "${comment}" \
| base64 -d \
| sed 's@^\(["'"'"']\)\(.*\)\1@\2@' \
| decode
)" \
"${email}"
done
|