[Rt-commit] rt branch, 5.0/support-gpg2, updated. rt-5.0.0alpha1-27-g4cf7e6562c

Aaron Trevena ast at bestpractical.com
Thu May 14 08:42:09 EDT 2020


The branch, 5.0/support-gpg2 has been updated
       via  4cf7e6562ca7d7b553943f2a176ee99fc4664059 (commit)
      from  a422e5845815745d8fa546bbb2f63d3e94e7310c (commit)

Summary of changes:
 lib/RT/Crypt/GnuPG.pm | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

- Log -----------------------------------------------------------------
commit 4cf7e6562ca7d7b553943f2a176ee99fc4664059
Author: Aaron Trevena <ast at bestpractical.com>
Date:   Thu May 14 13:41:45 2020 +0100

    Improved gnupgoptions configuration parsing to be more robust

diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 0898fc48df..df02efdd90 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -405,6 +405,7 @@ sub CallGnuPG {
             $err ||= "Can't close gnupg $_ handle: $!";
         }
     }
+
     $RT::Logger->debug( $res{'status'} ) if $res{'status'};
     $RT::Logger->warning( $res{'stderr'} ) if $res{'stderr'};
     $RT::Logger->error( $res{'logger'} ) if $res{'logger'} && $?;
@@ -1607,12 +1608,16 @@ sub _ParseUserHint {
 
 sub _PrepareGnuPGOptions {
     my %opt = @_;
-    my %res = map { lc $_ => $opt{ $_ } } grep $supported_opt{ lc $_ }, keys %opt;
-    $res{'extra_args'} ||= [];
-    foreach my $o ( grep !$supported_opt{ lc $_ }, keys %opt ) {
-        push @{ $res{'extra_args'} }, '--'. lc $o;
-        push @{ $res{'extra_args'} }, $opt{ $o }
-            if defined $opt{ $o };
+    my %res = ( extra_args => (delete $opt{extra_args} // [ ]) );
+    foreach my $raw_opt (keys %opt) {
+        (my $clean_opt = lc ($raw_opt) ) =~ s/\-/_/g;
+        if ($supported_opt{$clean_opt}) {
+            $res{$clean_opt} = $opt{$raw_opt};
+        } else {
+            push @{ $res{'extra_args'} }, '--'. lc $raw_opt;
+            push @{ $res{'extra_args'} }, $opt{ $raw_opt }
+                if defined $opt{ $raw_opt };
+        }
     }
     return %res;
 }

-----------------------------------------------------------------------


More information about the rt-commit mailing list