]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/CGI.pm
Make munge_url use repeatable sorting
[debbugs.git] / Debbugs / CGI.pm
index 980a71d0b963e23d81a71a750c2592a8998ca954..3632f3f869b585665a896a108b88cab25f4fa8b3 100644 (file)
@@ -161,7 +161,9 @@ sub munge_url {
      while (my ($key,$value) = splice @old_param,0,2) {
          push @new_param,($key,$value) unless exists $params{$key};
      }
-     $new_url->query_form(@new_param,%params);
+     $new_url->query_form(@new_param,
+                         map {($_,$params{$_})}
+                         sort keys %params);
      return $new_url->as_string;
 }
 
@@ -196,7 +198,7 @@ width and height are passed.
 
 sub version_url{
      my %params = validate_with(params => \@_,
-                               spec   => {package => {type => SCALAR,
+                               spec   => {package => {type => SCALAR|ARRAYREF,
                                                      },
                                           found   => {type => ARRAYREF,
                                                       default => [],
@@ -297,7 +299,7 @@ sub quitcgi {
 }
 
 
-=head HTML
+=head1 HTML
 
 =head2 htmlize_packagelinks
 
@@ -400,11 +402,15 @@ sub package_links {
      }
      my @links = ();
      for my $type (qw(src package)) {
-         push @links, map {(munge_url('pkgreport.cgi?',
+         push @links, map {my $t_type = $type;
+                           if ($_ =~ s/^src://) {
+                               $t_type = 'src';
+                           }
+                           (munge_url('pkgreport.cgi?',
                                       %options,
-                                      $type => $_,
+                                      $t_type => $_,
                                      ),
-                            $_);
+                            ($t_type eq 'src'?'src:':'').$_);
                       } make_list($param{$type}) if exists $param{$type};
      }
      for my $type (qw(maint owner submitter correspondent)) {
@@ -536,8 +542,8 @@ the split links with commas and spaces.
 sub maybelink {
     my ($links,$regex,$join) = @_;
     if (not defined $regex and not defined $join) {
-        $links =~ s{((?:ftp|http|https)://[\S~-]+?/?)([\)\'\:\.\,]?(?:\s|\.<|$))}
-                   {q(<a href=").html_escape($1).q(">).html_escape($1).q(</a>).$2}geimo;
+        $links =~ s{(.*?)((?:(?:ftp|http|https)://[\S~-]+?/?)?)([\)\'\:\.\,]?(?:\s|\.<|$))}
+                   {html_escape($1).(length $2?q(<a href=").html_escape($2).q(">).html_escape($2).q(</a>):'').html_escape($3)}geimo;
         return $links;
     }
     $join = ' ' if not defined $join;