diff options
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/version/lib/version.pm | 6 | ||||
-rw-r--r-- | cpan/version/lib/version/regex.pm | 16 | ||||
-rw-r--r-- | cpan/version/t/01base.t | 8 | ||||
-rw-r--r-- | cpan/version/t/02derived.t | 8 | ||||
-rw-r--r-- | cpan/version/t/03require.t | 8 | ||||
-rw-r--r-- | cpan/version/t/04strict_lax.t | 15 | ||||
-rw-r--r-- | cpan/version/t/05sigdie.t | 2 | ||||
-rw-r--r-- | cpan/version/t/06noop.t | 2 | ||||
-rw-r--r-- | cpan/version/t/07locale.t | 2 | ||||
-rw-r--r-- | cpan/version/t/08_corelist.t | 2 | ||||
-rw-r--r-- | cpan/version/t/09_list_util.t | 2 | ||||
-rw-r--r-- | cpan/version/t/11_taint.t | 24 |
12 files changed, 74 insertions, 21 deletions
diff --git a/cpan/version/lib/version.pm b/cpan/version/lib/version.pm index 36d130f2dc..c85e8a029b 100644 --- a/cpan/version/lib/version.pm +++ b/cpan/version/lib/version.pm @@ -10,7 +10,7 @@ if ($] >= 5.015) { use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv); -$VERSION = 0.9917; +$VERSION = 0.9918; $CLASS = 'version'; # avoid using Exporter @@ -18,7 +18,11 @@ require version::regex; *version::is_lax = \&version::regex::is_lax; *version::is_strict = \&version::regex::is_strict; *LAX = \$version::regex::LAX; +*LAX_DECIMAL_VERSION = \$version::regex::LAX_DECIMAL_VERSION; +*LAX_DOTTED_DECIMAL_VERSION = \$version::regex::LAX_DOTTED_DECIMAL_VERSION; *STRICT = \$version::regex::STRICT; +*STRICT_DECIMAL_VERSION = \$version::regex::STRICT_DECIMAL_VERSION; +*STRICT_DOTTED_DECIMAL_VERSION = \$version::regex::STRICT_DOTTED_DECIMAL_VERSION; sub import { no strict 'refs'; diff --git a/cpan/version/lib/version/regex.pm b/cpan/version/lib/version/regex.pm index d635c38d4b..8d66e19c00 100644 --- a/cpan/version/lib/version/regex.pm +++ b/cpan/version/lib/version/regex.pm @@ -2,9 +2,13 @@ package version::regex; use strict; -use vars qw($VERSION $CLASS $STRICT $LAX); +use vars qw( + $VERSION $CLASS $STRICT $LAX + $STRICT_DECIMAL_VERSION $STRICT_DOTTED_DECIMAL_VERSION + $LAX_DECIMAL_VERSION $LAX_DOTTED_DECIMAL_VERSION +); -$VERSION = 0.9917; +$VERSION = 0.9918; #--------------------------------------------------------------------------# # Version regexp components @@ -57,13 +61,13 @@ my $LAX_ALPHA_PART = qr/_[0-9]+/; # Strict decimal version number. -my $STRICT_DECIMAL_VERSION = +$STRICT_DECIMAL_VERSION = qr/ $STRICT_INTEGER_PART $FRACTION_PART? /x; # Strict dotted-decimal version number. Must have both leading "v" and # at least three parts, to avoid confusion with decimal syntax. -my $STRICT_DOTTED_DECIMAL_VERSION = +$STRICT_DOTTED_DECIMAL_VERSION = qr/ v $STRICT_INTEGER_PART $STRICT_DOTTED_DECIMAL_PART{2,} /x; # Complete strict version number syntax -- should generally be used @@ -80,7 +84,7 @@ $STRICT = # allowing an alpha suffix or allowing a leading or trailing # decimal-point -my $LAX_DECIMAL_VERSION = +$LAX_DECIMAL_VERSION = qr/ $LAX_INTEGER_PART (?: $FRACTION_PART | \. )? $LAX_ALPHA_PART? | $FRACTION_PART $LAX_ALPHA_PART? @@ -92,7 +96,7 @@ my $LAX_DECIMAL_VERSION = # enough, without the leading "v", Perl takes .1.2 to mean v0.1.2, # so when there is no "v", the leading part is optional -my $LAX_DOTTED_DECIMAL_VERSION = +$LAX_DOTTED_DECIMAL_VERSION = qr/ v $LAX_INTEGER_PART (?: $LAX_DOTTED_DECIMAL_PART+ $LAX_ALPHA_PART? )? | diff --git a/cpan/version/t/01base.t b/cpan/version/t/01base.t index 8e5ab71ce8..df0f6f096e 100644 --- a/cpan/version/t/01base.t +++ b/cpan/version/t/01base.t @@ -8,11 +8,13 @@ use Test::More qw/no_plan/; use File::Spec; BEGIN { - my $coretests = File::Spec->catpath( - (File::Spec->splitpath($0))[0,1], 'coretests.pm' + my $coretests = File::Spec->rel2abs( + File::Spec->catpath( + (File::Spec->splitpath($0))[0,1], 'coretests.pm' + ) ); require $coretests; - use_ok('version', 0.9917); + use_ok('version', 0.9918); } BaseTests("version","new","qv"); diff --git a/cpan/version/t/02derived.t b/cpan/version/t/02derived.t index fb77270342..3191c9ad1a 100644 --- a/cpan/version/t/02derived.t +++ b/cpan/version/t/02derived.t @@ -9,11 +9,13 @@ use File::Spec; use File::Temp qw/tempfile/; BEGIN { - my $coretests = File::Spec->catpath( - (File::Spec->splitpath($0))[0,1], 'coretests.pm' + my $coretests = File::Spec->rel2abs( + File::Spec->catpath( + (File::Spec->splitpath($0))[0,1], 'coretests.pm' + ) ); require $coretests; - use_ok("version", 0.9917); + use_ok("version", 0.9918); # If we made it this far, we are ok. } diff --git a/cpan/version/t/03require.t b/cpan/version/t/03require.t index 6a968a5324..d4744867b4 100644 --- a/cpan/version/t/03require.t +++ b/cpan/version/t/03require.t @@ -8,8 +8,10 @@ use Test::More qw/no_plan/; use File::Spec; BEGIN { - my $coretests = File::Spec->catpath( - (File::Spec->splitpath($0))[0,1], 'coretests.pm' + my $coretests = File::Spec->rel2abs( + File::Spec->catpath( + (File::Spec->splitpath($0))[0,1], 'coretests.pm' + ) ); require $coretests; } @@ -17,7 +19,7 @@ BEGIN { # Don't want to use, because we need to make sure that the import doesn't # fire just yet (some code does this to avoid importing qv() and delare()). require_ok("version"); -is $version::VERSION, 0.9917, "Make sure we have the correct class"; +is $version::VERSION, 0.9918, "Make sure we have the correct class"; ok(!"main"->can("qv"), "We don't have the imported qv()"); ok(!"main"->can("declare"), "We don't have the imported declare()"); diff --git a/cpan/version/t/04strict_lax.t b/cpan/version/t/04strict_lax.t index 298fcf7f6f..861e4df2b5 100644 --- a/cpan/version/t/04strict_lax.t +++ b/cpan/version/t/04strict_lax.t @@ -21,6 +21,21 @@ SKIP: { ($v) = ( "snapshot-v1.2.3ga-001-432" =~ /($version::STRICT)/ ); is $v, 'v1.2.3', "Extract just the version: $v"; } + + is ref($version::LAX_DECIMAL_VERSION), 'Regexp', 'Can see $version::LAX_DECIMAL_VERSION '.$version::LAX_DECIMAL_VERSION ; + is ref($version::LAX_DOTTED_DECIMAL_VERSION), 'Regexp', 'Can see $version::LAX_DOTTED_DECIMAL_VERSION '.$version::LAX_DOTTED_DECIMAL_VERSION ; + is ref($version::STRICT_DECIMAL_VERSION), 'Regexp', 'Can see $version::STRICT_DECIMAL_VERSION '.$version::STRICT_DECIMAL_VERSION; + is ref($version::STRICT_DOTTED_DECIMAL_VERSION), 'Regexp', 'Can see $version::STRICT_DOTTED_DECIMAL_VERSION '.$version::STRICT_DOTTED_DECIMAL_VERSION; + { # https://rt.cpan.org/Ticket/Display.html?id=119669 + ($v) = ( "snapshot-1.2.3ga-001-432" =~ /($version::LAX_DOTTED_DECIMAL_VERSION)/ ); + is $v, '1.2.3', "Extract just the version: $v"; + ($v) = ( "snapshot-1.2ga-001-432" =~ /($version::LAX_DECIMAL_VERSION)/ ); + is $v, '1.2', "Extract just the version: $v"; + ($v) = ( "snapshot-v1.2.3ga-001-432" =~ /($version::STRICT_DOTTED_DECIMAL_VERSION)/ ); + is $v, 'v1.2.3', "Extract just the version: $v"; + ($v) = ( "snapshot-1.2ga-001-432" =~ /($version::STRICT_DECIMAL_VERSION)/ ); + is $v, '1.2', "Extract just the version: $v"; + } } diff --git a/cpan/version/t/05sigdie.t b/cpan/version/t/05sigdie.t index 6776adc164..3801a35ad6 100644 --- a/cpan/version/t/05sigdie.t +++ b/cpan/version/t/05sigdie.t @@ -14,7 +14,7 @@ BEGIN { } BEGIN { - use version 0.9917; + use version 0.9918; } pass "Didn't get caught by the wrong DIE handler, which is a good thing"; diff --git a/cpan/version/t/06noop.t b/cpan/version/t/06noop.t index f118786ffc..6c6de7f4f3 100644 --- a/cpan/version/t/06noop.t +++ b/cpan/version/t/06noop.t @@ -7,7 +7,7 @@ use Test::More qw/no_plan/; BEGIN { - use_ok('version', 0.9917); + use_ok('version', 0.9918); } my $v1 = version->new('1.2'); diff --git a/cpan/version/t/07locale.t b/cpan/version/t/07locale.t index 1dcc6db31a..a197bdcf16 100644 --- a/cpan/version/t/07locale.t +++ b/cpan/version/t/07locale.t @@ -11,7 +11,7 @@ use Test::More tests => 8; use Config; BEGIN { - use_ok('version', 0.9917); + use_ok('version', 0.9918); } SKIP: { diff --git a/cpan/version/t/08_corelist.t b/cpan/version/t/08_corelist.t index 4678c14926..92a76bdf78 100644 --- a/cpan/version/t/08_corelist.t +++ b/cpan/version/t/08_corelist.t @@ -5,7 +5,7 @@ ######################### use Test::More tests => 3; -use_ok("version", 0.9917); +use_ok("version", 0.9918); # do strict lax tests in a sub to isolate a package to test importing SKIP: { diff --git a/cpan/version/t/09_list_util.t b/cpan/version/t/09_list_util.t index 6e94839ab8..a263c2d47f 100644 --- a/cpan/version/t/09_list_util.t +++ b/cpan/version/t/09_list_util.t @@ -4,7 +4,7 @@ ######################### use strict; -use_ok("version", 0.9917); +use_ok("version", 0.9918); use Test::More; BEGIN { diff --git a/cpan/version/t/11_taint.t b/cpan/version/t/11_taint.t new file mode 100644 index 0000000000..5307b01268 --- /dev/null +++ b/cpan/version/t/11_taint.t @@ -0,0 +1,24 @@ +#!perl -T +use Test::More; +use version; + +BEGIN { + eval "use Test::Taint"; + if ($@) { + plan skip_all => "No Test::Taint available"; + } else { + plan tests => 6; + } +} + +taint_checking_ok(); +my $v = 'v1.2.3'; +taint($v); +tainted_ok($v, 'Set string as tainted'); +my $v2 = version->parse($v); +isnt("$v2", '', 'Correctly parsed the tainted string'); +tainted_ok($v2, 'Resulting version object is tainted'); + +my $vs = "$v2"; +tainted_ok($vs, 'Stringified object still tainted'); +is $v2, 'v1.2.3', 'Comparison to tainted object'; |