diff options
author | Alvaro Herrera | 2008-11-28 17:14:03 +0000 |
---|---|---|
committer | Alvaro Herrera | 2008-11-28 17:14:03 +0000 |
commit | 652bcc0c5c2552edcafa50ae947c53a833ce48f2 (patch) | |
tree | a373fa63fef6d9d7d6e3a4e03011839b06156e71 | |
parent | 235f6f5216a235b96530062ee9f2573ebe0d49b7 (diff) |
Make it work with & in message-ids
git-svn-id: file:///Users/dpage/pgweb/svn-repo/trunk@2319 8f5c7a92-453e-0410-a47f-ad33c8a6b003
-rwxr-xr-x | archives/bin/msgid2link.pl | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/archives/bin/msgid2link.pl b/archives/bin/msgid2link.pl index 5e8795f5..db990d0a 100755 --- a/archives/bin/msgid2link.pl +++ b/archives/bin/msgid2link.pl @@ -18,7 +18,7 @@ my $DIR = $ARGV[0]; die "$DIR is not a directory\n" if (! -d $DIR); chdir $DIR or die "Cannot change directory to $DIR\n"; -for my $in_filename (glob("*.php")) +while (my $in_filename = glob("msg*.php")) { next if (! -f $in_filename); @@ -29,12 +29,26 @@ for my $in_filename (glob("*.php")) (my $OUT, my $out_filename) = tempfile(UNLINK => 1, DIR => '.'); while (<$IN>) { + # prevent running on a file we already processed, by + # adding our marker at the top of the file + last if (m/^<!-- msgid2link -->/); + if (m/^<!-- MHonArc/) + { + print $OUT "<!-- msgid2link -->\n"; + } + if (!$changes && m/>Message-id(<.*>)?:/ && !m/<a href=/) { s/\(dot\)/./g; s/\(at\)/@/g; - m/^(.*<)([^&]*)(>.*)$/; - print $OUT qq{$1<a href="http://archives.postgresql.org/message-id/$2">$2</a>$3}; + m/^(.*<)(.*)(><\/li>)$/; + my $lead = $1; + my $link = $2; + my $ulink = $2; + my $trailer = $3; + # do we need more HTML de-escaping? + $link =~ s/&/&/g; + print $OUT qq{$lead<a href="http://archives.postgresql.org/message-id/$link">$ulink</a>$trailer}; $changes = 1; } else @@ -52,6 +66,7 @@ for my $in_filename (glob("*.php")) sysdie "Cannot rename $out_filename to $in_filename"; # restore file permissions chmod $stat_in_file->mode & 07777, $in_filename; + print "done file $in_filename\n"; } else { |