]> git.sthu.org Git - pgp-tools.git/blob - keyanalyze/scripts/htmlify_report
Checked for policy 3.8.1, no changes necessary.
[pgp-tools.git] / keyanalyze / scripts / htmlify_report
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Getopt::Std;
5
6 my %options;
7 getopts('k:', \%options);
8 my $keyring = $options{k} ? "--no-default-keyring --keyring=$options{k}" : "";
9 my %UID;
10
11 sub get_uid {
12 my $key = shift;
13 return $UID{$key} if $UID{$key};
14 open G, "gpg --list-key --fixed-list-mode --with-colon $keyring $key |" or die "gpg: $!";
15 while(<G>) {
16 next unless /^uid:[-qmfue]::::\d*::[\dA-F]*::(.+):$/;
17 my $name = $1;
18 $name =~ s/</&lt;/g;
19 $name =~ s/>/&gt;/g;
20 $name =~ s/\@/&#64;/g;
21 close G;
22 return $UID{$key} = $name;
23 }
24 close G;
25 }
26
27 sub uid_link {
28 my $key = shift;
29 #$key =~ /^([\dA-F]{2})/;
30 #return "<a href=\"../$1/$key.html\">$key</a>";
31 return "<a href=\"$key.html\">$key</a>";
32 }
33
34 for my $file (@ARGV) {
35 #print STDERR "$file...\n";
36 open F, "$file" or die "$file: $!";
37 open H, ">$file.html" or die "$file.html: $!";
38 print H <<EOF;
39 <html>
40 <head>
41 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
42 <title>$file</title>
43 </head>
44 <body>
45 <pre>
46 EOF
47 while(<F>) {
48 next if /^(This individual|report at)/;
49 s/([\dA-F]{8})$/uid_link($1)." ".get_uid($1);/e;
50 print H;
51 }
52 print H "</pre>\n</body></html>\n";
53 }