summaryrefslogtreecommitdiff
path: root/cpan/version
diff options
context:
space:
mode:
authorJohn Peacock <jpeacock@cpan.org>2013-12-29 14:33:48 -0500
committerFather Chrysostomos <sprout@cpan.org>2014-01-04 05:10:04 -0800
commitab4e0d4b14df5832900d7298e29f41c86dcfc8ac (patch)
tree26eceb9a0c4adb5338eaf7d921fc244b4697ec57 /cpan/version
parent98079c483a238cb7ae83e3cd15c53cf7f1236457 (diff)
downloadperl-ab4e0d4b14df5832900d7298e29f41c86dcfc8ac.tar.gz
Do not crash if passed garbage like array.
Somehow we lost the test that caught getting passed an arrayref instead of a simple scalar. Also integrate fix from perl rt#120872.
Diffstat (limited to 'cpan/version')
-rw-r--r--cpan/version/lib/version/vpp.pm5
-rw-r--r--cpan/version/t/coretests.pm11
2 files changed, 16 insertions, 0 deletions
diff --git a/cpan/version/lib/version/vpp.pm b/cpan/version/lib/version/vpp.pm
index f6153a6c49..c879c398c8 100644
--- a/cpan/version/lib/version/vpp.pm
+++ b/cpan/version/lib/version/vpp.pm
@@ -674,6 +674,11 @@ sub new
$qv = TRUE;
}
+ if (ref($value) =~ m/ARRAY|HASH/) {
+ require Carp;
+ Carp::croak("Invalid version format (non-numeric data)");
+ }
+
$value = _un_vstring($value);
# exponential notation
diff --git a/cpan/version/t/coretests.pm b/cpan/version/t/coretests.pm
index b7b690aa8c..17bf9ec5fc 100644
--- a/cpan/version/t/coretests.pm
+++ b/cpan/version/t/coretests.pm
@@ -30,6 +30,10 @@ sub BaseTests {
$version = $CLASS->$method(1.23);
is ( "$version" , "1.23" , '1.23 eq "1.23"' );
+ # Test explicit integer
+ $version = $CLASS->$method(23);
+ is ( "$version" , 23 , '23 eq "23"' );
+
# Test quoted number processing
$version = $CLASS->$method("5.005_03");
is ( "$version" , "5.005_03" , '"5.005_03" eq "5.005_03"' );
@@ -582,6 +586,13 @@ SKIP: {
is ref(ver->qv("1.2.3")), 'ver', 'ver can inherit from version';
}
+ { # discovered while integrating with bleadperl
+ eval {my $v = $CLASS->new([1,2,3]) };
+ like $@, qr/Invalid version format/, 'Do not crash for garbage';
+ eval {my $v = $CLASS->new({1 => 2}) };
+ like $@, qr/Invalid version format/, 'Do not crash for garbage';
+ }
+
}
1;