]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Estraier.pm
default charset to UTF-8 when it isn't defined
[debbugs.git] / Debbugs / Estraier.pm
index f2f6cb8ebf098b9292104bba943e80b7546fb449..e3c89a1d6ce074c92c6d6b67c69609b4b50a6f23 100644 (file)
@@ -1,3 +1,9 @@
+# This module is part of debbugs, and is released
+# under the terms of the GPL version 2, or any later
+# version at your option.
+# See the file README and COPYING for more information.
+#
+# Copyright 2007 by Don Armstrong <don@donarmstrong.com>.
 
 package Debbugs::Estraier;
 
@@ -27,7 +33,7 @@ use Debbugs::Log;
 #use Params::Validate;
 use Search::Estraier;
 use Date::Manip;
-use Debbugs::Common qw(getbuglocation getbugcomponent);
+use Debbugs::Common qw(getbuglocation getbugcomponent make_list);
 use Debbugs::Status qw(readbug);
 use Debbugs::MIME qw(parse);
 
@@ -70,7 +76,7 @@ sub add_bug_log{
          my ($msg_id) = $record->{text} =~ /^Message-Id:\s+<(.+)>/im;
          next if defined $msg_id and exists $seen_msg_ids{$msg_id};
          $seen_msg_ids{$msg_id} = 1 if defined $msg_id;
-         next if $msg_id =~ /handler\..+\.ack(?:info)?\@/;
+         next if defined $msg_id and $msg_id =~ /handler\..+\.ack(?:info)?\@/;
          add_bug_message($est,$record->{text},$bug_num,$msg_num,$status)
      }
      return $msg_num;
@@ -115,7 +121,7 @@ sub add_bug_message{
      $doc = new Search::Estraier::Document if not defined $doc;
 
      my $message = parse($bug_message);
-     $doc->add_text(join('',values %{$message}));
+     $doc->add_text(join("\n",make_list(values %{$message})));
 
      # * @id : the ID number determined automatically when the document is registered.
      # * @uri : the location of a document which any document should have.
@@ -134,17 +140,17 @@ sub add_bug_message{
      my @attr = qw(status subject date submitter package tags severity);
      # parse the date
      my ($date) = $bug_message =~ /^Date:\s+(.+?)\s*$/mi;
-     $doc->add_attr('@cdate' => $date);
+     $doc->add_attr('@cdate' => $date) if defined $date;
      # parse the title
      my ($subject) = $bug_message =~ /^Subject:\s+(.+?)\s*$/mi;
-     $doc->add_attr('@title' => $subject);
+     $doc->add_attr('@title' => $subject) if defined $subject;
      # parse the author
      my ($author) = $bug_message =~ /^From:\s+(.+?)\s*$/mi;
-     $doc->add_attr('@author' => $author);
+     $doc->add_attr('@author' => $author) if defined $author;
      # create the uri
      $doc->add_attr('@uri' => $uri);
      foreach my $attr (@attr) {
-         $doc->add_attr($attr => $status->{$attr});
+         $doc->add_attr($attr => $status->{$attr}) if defined $status->{$attr};
      }
      print STDERR "adding $uri\n" if $DEBUG;
      # Try a bit harder if estraier is returning timeouts