Skip to content

Commit 3367a90

Browse files
committed
Be Perl 5.12 compatible
state in 5.12 does not allow list context Signed-off-by: Wesley Schwengle <[email protected]>
1 parent 0419da9 commit 3367a90

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

.github/workflows/linux.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
---
12
name: linux
23

34
on:
45
- push
6+
- pull_request
57

68
jobs:
79
perl:

lib/XML/Enc.pm

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ sub _decrypt_uri_nodes {
304304
my %options = @_;
305305

306306
my $uri_nodes = $xpc->findnodes('//dsig:KeyInfo/dsig:RetrievalMethod/@URI');
307-
my @uri_nodes = $uri_nodes->map(sub { my $v = $_->getValue; $v =~ s/^#//r });
307+
my @uri_nodes = $uri_nodes->map(sub { my $v = $_->getValue; $v =~ s/^#//; return $v; });
308308

309309
foreach my $uri (@uri_nodes) {
310310
my $encrypted_key_nodes = $self->_get_named_key_nodes(
@@ -547,43 +547,43 @@ sub _setOAEPAlgorithm {
547547
my $self = shift;
548548
my $method = shift;
549549

550-
my %methods = (
551-
'mgf1sha1' => 'http://www.w3.org/2009/xmlenc11#mgf1sha1',
552-
'mgf1sha224' => 'http://www.w3.org/2009/xmlenc11#mgf1sha224',
553-
'mgf1sha256' => 'http://www.w3.org/2009/xmlenc11#mgf1sha256',
554-
'mgf1sha384' => 'http://www.w3.org/2009/xmlenc11#mgf1sha384',
555-
'mgf1sha512' => 'http://www.w3.org/2009/xmlenc11#mgf1sha512',
556-
);
550+
state $setOAEPAlgorithm = {
551+
'mgf1sha1' => 'http://www.w3.org/2009/xmlenc11#mgf1sha1',
552+
'mgf1sha224' => 'http://www.w3.org/2009/xmlenc11#mgf1sha224',
553+
'mgf1sha256' => 'http://www.w3.org/2009/xmlenc11#mgf1sha256',
554+
'mgf1sha384' => 'http://www.w3.org/2009/xmlenc11#mgf1sha384',
555+
'mgf1sha512' => 'http://www.w3.org/2009/xmlenc11#mgf1sha512',
556+
};
557557

558-
return exists($methods{$method}) ? $methods{$method} : $methods{'mgf1sha1'};
558+
return $setOAEPAlgorithm->{$method} // $setOAEPAlgorithm->{'rsa-oaep-mgf1p'};
559559
}
560560

561561
sub _getOAEPAlgorithm {
562562
my $self = shift;
563563
my $method = shift;
564564

565-
state %OAEPAlgorithm = (
565+
state $OAEPAlgorithm = {
566566
'http://www.w3.org/2009/xmlenc11#mgf1sha1' => 'SHA1',
567567
'http://www.w3.org/2009/xmlenc11#mgf1sha224' => 'SHA224',
568568
'http://www.w3.org/2009/xmlenc11#mgf1sha256' => 'SHA256',
569569
'http://www.w3.org/2009/xmlenc11#mgf1sha384' => 'SHA384',
570570
'http://www.w3.org/2009/xmlenc11#mgf1sha512' => 'SHA512',
571-
);
571+
};
572572

573-
return $OAEPAlgorithm{$method} // 'SHA1';
573+
return $OAEPAlgorithm->{$method} // 'SHA1';
574574
}
575575

576576
sub _setKeyEncryptionMethod {
577577
my $self = shift;
578578
my $method = shift;
579579

580-
my %methods = (
581-
'rsa-1_5' => 'http://www.w3.org/2001/04/xmlenc#rsa-1_5',
582-
'rsa-oaep-mgf1p' => 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p',
583-
'rsa-oaep' => 'http://www.w3.org/2009/xmlenc11#rsa-oaep',
584-
);
580+
state $enc_methods = {
581+
'rsa-1_5' => 'http://www.w3.org/2001/04/xmlenc#rsa-1_5',
582+
'rsa-oaep-mgf1p' => 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p',
583+
'rsa-oaep' => 'http://www.w3.org/2009/xmlenc11#rsa-oaep',
584+
};
585585

586-
return exists($methods{$method}) ? $methods{$method} : $methods{'rsa-oaep-mgf1p'};
586+
return $enc_methods->{$method} // $enc_methods->{'rsa-oaep-mgf1p'};
587587
}
588588

589589
sub _DecryptData {

0 commit comments

Comments
 (0)