Manage carriage return in crypted values (#709)
This commit is contained in:
parent
50b80020da
commit
f5e3019ff1
|
@ -14,7 +14,7 @@ use MIME::Base64;
|
|||
use Digest::MD5 qw(md5);
|
||||
use bytes;
|
||||
|
||||
our $VERSION = '1.2.3';
|
||||
our $VERSION = '1.4.0';
|
||||
|
||||
our $msg;
|
||||
|
||||
|
@ -80,6 +80,7 @@ sub decrypt {
|
|||
$data =~ s/%2B/\+/ig;
|
||||
$data =~ s/%2F/\//ig;
|
||||
$data =~ s/%3D/=/ig;
|
||||
$data =~ s/%0A/\n/ig;
|
||||
eval { $data = $self->_getCipher->decrypt( decode_base64($data) ); };
|
||||
if ($@) {
|
||||
$msg = "Crypt::Rijndael error : $@";
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
# change 'tests => 1' to 'tests => last_test_to_print';
|
||||
|
||||
use Test::More tests => 20;
|
||||
use Test::More tests => 21;
|
||||
use Digest::MD5 qw(md5 md5_hex md5_base64);
|
||||
use strict;
|
||||
|
||||
|
@ -39,3 +39,8 @@ ok(
|
|||
$c->decryptHex( $c->encryptHex( $data, $secondKey ), $secondKey ) eq $data,
|
||||
"Test of hexadecimal encrypting"
|
||||
);
|
||||
|
||||
# Test a long value, and replace carriage return by %0A
|
||||
my $long = "f5a1f72e7ab2f7712855a068af0066f36bfcf2c87e6feb9cf4200da1868e1dfe";
|
||||
my $cryptedlong ="Da6sYxp9NCXv8+8TirqHmPWwTQHyEGmkCBGCLCX/81dPSMwIQVQNV7X9KG3RrKZfyRmzJR6DZYdU%0Ab75+VH3+CA==";
|
||||
ok ( $c->decrypt( $cryptedlong ) eq $long, "Test of long value encrypting" );
|
||||
|
|
Loading…
Reference in New Issue
Block a user