]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Status.pm
* fix extraneous semicolon
[debbugs.git] / Debbugs / Status.pm
index 00516b404d30ddd0bfbf56f954ea6e5fdcc119d0..8b4b9b045164363d14371e5336223ac20f373663 100644 (file)
@@ -40,7 +40,7 @@ use Params::Validate qw(validate_with :types);
 use Debbugs::Common qw(:util :lock :quit :misc);
 use Debbugs::Config qw(:config);
 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
-use Debbugs::Packages qw(makesourceversions make_source_versions getversions get_versions binarytosource);
+use Debbugs::Packages qw(makesourceversions make_source_versions getversions get_versions binary_to_source);
 use Debbugs::Versions;
 use Debbugs::Versions::Dpkg;
 use POSIX qw(ceil);
@@ -232,7 +232,11 @@ sub read_bug{
     for my $line (@lines) {
         if ($line =~ /(\S+?): (.*)/) {
             my ($name, $value) = (lc $1, $2);
-            $data{$namemap{$name}} = $value if exists $namemap{$name};
+           # this is a bit of a hack; we should never, ever have \r
+           # or \n in the fields of status. Kill them off here.
+           # [Eventually, this should be superfluous.]
+           $value =~ s/[\r\n]//g;
+           $data{$namemap{$name}} = $value if exists $namemap{$name};
         }
     }
     for my $field (keys %fields) {
@@ -522,6 +526,13 @@ sub makestatus {
         }
     }
 
+    # this is a bit of a hack; we should never, ever have \r or \n in
+    # the fields of status. Kill them off here. [Eventually, this
+    # should be superfluous.]
+    for my $field (keys %newdata) {
+       $newdata{$field} =~ s/[\r\n]//g if defined $newdata{$field};
+    }
+
     if ($version == 1) {
         for my $field (@v1fieldorder) {
             if (exists $newdata{$field} and defined $newdata{$field}) {
@@ -608,7 +619,7 @@ The following functions are exported with the :versions tag
 
      addfoundversions($status,$package,$version,$isbinary);
 
-
+All use of this should be phased out in favor of Debbugs::Control::fixed/found
 
 =cut
 
@@ -621,9 +632,14 @@ sub addfoundversions {
     return unless defined $version;
     undef $package if $package =~ m[(?:\s|/)];
     my $source = $package;
+    if ($package =~ s/^src://) {
+       $isbinary = 0;
+       $source = $package;
+    }
 
     if (defined $package and $isbinary) {
-        my @srcinfo = binarytosource($package, $version, undef);
+        my @srcinfo = binary_to_source(binary => $package,
+                                      version => $version);
         if (@srcinfo) {
             # We know the source package(s). Use a fully-qualified version.
             addfoundversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
@@ -697,7 +713,8 @@ sub addfixedversions {
     my $source = $package;
 
     if (defined $package and $isbinary) {
-        my @srcinfo = binarytosource($package, $version, undef);
+        my @srcinfo = binary_to_source(binary => $package,
+                                      version => $version);
         if (@srcinfo) {
             # We know the source package(s). Use a fully-qualified version.
             addfixedversions($data, $_->[0], $_->[1], '') foreach @srcinfo;
@@ -1059,25 +1076,10 @@ sub get_bug_status {
 
      $status{package} = '' if not defined $status{package};
      $status{"package"} =~ s/\s*$//;
-     # if we aren't supposed to indicate the source, we'll return
-     # unknown here.
-     $status{source} = 'unknown';
-     if ($param{indicatesource}) {
-        my @packages = split /\s*,\s*/, $status{package};
-        my @source;
-        for my $package (@packages) {
-            next if $package eq '';
-            if ($package =~ /^src\:(.+)$/) {
-                push @source,$1;
-            }
-            else {
-                push @source, binarytosource($package);
-            }
-        }
-        if (@source) {
-            $status{source} = join(', ',@source);
-        }
-     }
+
+     $status{source} = binary_to_source(binary=>[split /\s*,\s*/, $status{package}],
+                                       source_only => 1,
+                                      );
 
      $status{"package"} = 'unknown' if ($status{"package"} eq '');
      $status{"severity"} = 'normal' if (not defined $status{severity} or $status{"severity"} eq '');