Package: l10n-bot
Version:
Status: applied
Author: Guillem Jover <guillem@debian.org>
Description:
 Demangle quoted-printable subjects correctly.
 Convert some consants to variables.

--- old/l10n-bot	2004-02-07 21:49:39.000000000 +0100
+++ new/l10n-bot	2004-02-07 21:56:24.000000000 +0100
@@ -2,6 +2,7 @@
 #
 # l10n-bot -- Parse emails on stdin for psuedo-urls used on debian-l10n-*@
 # Copyright (C) 2003-2004 Tim Dijkstra
+# Copyrigth (C) 2004 Guillem Jover
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -26,10 +27,29 @@
 #  will be saved to disk.
 #  See also pseudo-urls.html
 
+use Text::Iconv;
 use MIME::Parser;
+use MIME::WordDecoder;
 use DBI;
 
-# Search recursively all entity filenames
+my $db_name = "debian_l10n_ca";
+my $db_user = "debian";
+my $db_passwd = "foo";
+my $dir = "/site/ca.debian.net/www";
+
+sub cvt_utf8
+{
+  my ($data, $charset, $decoder) = @_ ;
+
+  if ($data) {
+    my $converter = Text::Iconv->new($charset, "UTF-8");
+    return $converter->convert($data);
+  } else {
+    return "";
+  }
+}
+
+# Recursive routine for finding the entity filenames.
 sub get_entity_filenames {
     my ($entity) = @_;
     my @files;
@@ -56,7 +76,6 @@
 
 ### Create parser, and set some parsing options:
 my $parser = new MIME::Parser;
-my $dir = "/var/www/www.famdijkstra.org/debian/l10n";
 $parser->output_dir("/tmp");
 
 ### Parse input:
@@ -74,8 +93,13 @@
 $name = $3;
 $date = Date::Format::time2str "%Y%m%d%H%M%S", Date::Parse::str2time($head->get('Date'));
 
+# Create a word quoted-printable converter
+my $wd = new MIME::WordDecoder;
+$wd->handler('UTF-8' => "KEEP", 'US-ASCII' => "KEEP", 'raw' => "KEEP",
+	     '*' => \&cvt_utf8);
+
 # Cut out e-mail adres, trim name
-$translator = $head->get('From');
+$translator = $wd->decode($head->get('From'));
 $translator =~ s/\s<[^>]*>\s//;
 $translator =~ s/^\s*([^\s]*)\s*$/$1/;
 $file=0;
@@ -105,8 +129,8 @@
    }
 }
 
-$dsn="DBI:mysql:database=debian;host=localhost;port=3306";
-$link = DBI->connect($dsn, "USER","PASSWORD");
+$dsn = "DBI:mysql:database=$db_name;host=localhost;port=3306";
+$link = DBI->connect($dsn, $db_user, $db_passwd);
 
 # If we have an ITT, we can have multiple packagename {php4,apache,mysql}
 ($status =~ /^ITT$/) and ($name =~ s/{([^}]*)}/$1/);
