[Rt-commit] rt branch, 5.0/gnupg-file-extensions, created. rt-5.0.0-52-g0896e8ca80
? sunnavy
sunnavy at bestpractical.com
Fri Oct 9 10:49:43 EDT 2020
The branch, 5.0/gnupg-file-extensions has been created
at 0896e8ca802e769fa92cb05caf2016d4531c464f (commit)
- Log -----------------------------------------------------------------
commit 09d03967b7fabd1468de8e5f5d2f55dc4aa2e095
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Oct 9 21:54:21 2020 +0800
Make GnuPG file extensions more easily configurable
Previously it could be customized by overriding package variable
$RT::Crypt::GnuPG::RE_FILE_EXTENSIONS, which is not as straightforward
as a config item.
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 1e573155dc..e4186c2ae7 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -3869,6 +3869,7 @@ Set(%GnuPG,
GnuPG => 'gpg',
Passphrase => undef,
OutgoingMessagesFormat => "RFC", # Inline
+ FileExtensions => [ 'pgp', 'asc' ],
);
=item C<%GnuPGOptions>
diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 517b70374b..86866e1e6d 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -287,8 +287,6 @@ my %supported_opt = map { $_ => 1 } qw(
verbose
);
-our $RE_FILE_EXTENSIONS = qr/pgp|asc/i;
-
# DEV WARNING: always pass all STD* handles to GnuPG interface even if we don't
# need them, just pass 'IO::Handle->new()' and then close it after safe_run_child.
# we don't want to leak anything into FCGI/Apache/MP handles, this break things.
@@ -826,12 +824,13 @@ sub FindScatteredParts {
}
}
+ my $file_extension_regex = join '|', @{ RT->Config->Get('GnuPG')->{FileExtensions} };
# attachments with inline encryption
foreach my $part ( @parts ) {
next if $args{'Skip'}{$part};
my $fname = $part->head->recommended_filename || '';
- next unless $fname =~ /\.${RE_FILE_EXTENSIONS}$/;
+ next unless $fname =~ /\.(?:$file_extension_regex)$/;
$RT::Logger->debug("Found encrypted attachment '$fname'");
@@ -850,7 +849,7 @@ sub FindScatteredParts {
my $type = $self->_CheckIfProtectedInline( $part );
next unless $type;
- my $file = ($part->head->recommended_filename||'') =~ /\.${RE_FILE_EXTENSIONS}$/;
+ my $file = ($part->head->recommended_filename||'') =~ /\.(?:$file_extension_regex)$/;
$args{'Skip'}{$part} = 1;
push @res, {
@@ -1237,7 +1236,8 @@ sub DecryptAttachment {
}
my $filename = $embedded_fn || $head->recommended_filename;
- $filename =~ s/\.${RE_FILE_EXTENSIONS}$//i;
+ my $file_extension_regex = join '|', @{ RT->Config->Get('GnuPG')->{FileExtensions} };
+ $filename =~ s/\.(?:$file_extension_regex)$//i;
$head->mime_attr( $_ => $filename )
foreach (qw(Content-Type.name Content-Disposition.filename));
commit 0896e8ca802e769fa92cb05caf2016d4531c464f
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Oct 9 21:57:01 2020 +0800
Add .gpg file extension support to RT::Crypt::GnuPG
As ".gpg" is the default extension of files encrypted by gpg, it's good
to support it by default.
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index e4186c2ae7..8049bd0f7d 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -3869,7 +3869,7 @@ Set(%GnuPG,
GnuPG => 'gpg',
Passphrase => undef,
OutgoingMessagesFormat => "RFC", # Inline
- FileExtensions => [ 'pgp', 'asc' ],
+ FileExtensions => [ 'pgp', 'gpg', 'asc' ],
);
=item C<%GnuPGOptions>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list