cpan/version/t/08_corelist.t Tests for version objects
cpan/version/t/09_list_util.t Tests for version objects
cpan/version/t/10_lyon.t Tests for version objects
+cpan/version/t/11_taint.t Tests for version objects
cpan/version/t/coretests.pm Tests for version objects
cpan/Win32/longpath.inc Win32 extension long path support
cpan/Win32/Makefile.PL Win32 extension makefile writer
use vars qw(@ISA $VERSION $CLASS $STRICT $LAX *declare *qv);
-$VERSION = 0.9917;
+$VERSION = 0.9918;
$CLASS = 'version';
# avoid using Exporter
*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';
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
# 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
# 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?
# 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? )?
|
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");
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.
}
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;
}
# 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()");
($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";
+ }
}
}
BEGIN {
- use version 0.9917;
+ use version 0.9918;
}
pass "Didn't get caught by the wrong DIE handler, which is a good thing";
use Test::More qw/no_plan/;
BEGIN {
- use_ok('version', 0.9917);
+ use_ok('version', 0.9918);
}
my $v1 = version->new('1.2');
use Config;
BEGIN {
- use_ok('version', 0.9917);
+ use_ok('version', 0.9918);
}
SKIP: {
#########################
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: {
#########################
use strict;
-use_ok("version", 0.9917);
+use_ok("version", 0.9918);
use Test::More;
BEGIN {
--- /dev/null
+#!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';
Test::Harness cpan/Test-Harness/lib/Test/Harness.pm da2d76ba673372da129060c9d0adb8cf0d91f9f7
Test::Simple cpan/Test-Simple/t/Test2/modules/IPC/Driver/Files.t 59648b5745fda06177d81c2c21f55b09f6e129bb
autodie cpan/autodie/t/mkdir.t 9e70d2282a3cc7d76a78bf8144fccba20fb37dac
-version cpan/version/lib/version.pm a032a751524bdd07a93c945d2a1703abe7ad8ef0
+version cpan/version/lib/version.pm bee369df1bd84e09107a90d72ec12c38bcb97cce
if (svp) {
SV *pv;
pv = *svp;
- if ( SvPOK(pv) )
+ if ( SvPOK(pv)
+#if PERL_VERSION_LT(5,17,2)
+ || SvPOKp(pv)
+#endif
+ )
return newSVsv(pv);
else
return &PL_sv_undef;
Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
} else {
/* Pants. I don't think that it should be possible to get here. */
- Perl_croak_nocontext("Usage: CODE(0x%"UVxf")(%s)", PTR2UV(cv), params);
+ Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
}
}
name, SvPVx_nolen_const(req));
#else
Perl_croak(aTHX_
- "%"HEKf" does not define $%"HEKf
+ "%" HEKf " does not define $%"HEKf
"::VERSION--version check failed",
HEKfARG(name), HEKfARG(name));
#endif
else {
#if PERL_VERSION >= 8
Perl_croak(aTHX_
- "%"SVf" defines neither package nor VERSION--version check failed",
+ "%" SVf " defines neither package nor VERSION--"
+ "version check failed",
(void*)(ST(0)) );
#else
Perl_croak(aTHX_ "%s does not define $%s::VERSION--version check failed",
}
if ( VCMP( req, sv ) > 0 ) {
- if ( hv_existss(MUTABLE_HV(SvRV(req)), "qv") ) {
+ if ( hv_exists(MUTABLE_HV(SvRV(req)), "qv", 2 ) ) {
req = VNORMAL(req);
sv = VNORMAL(sv);
}
req = VSTRINGIFY(req);
sv = VSTRINGIFY(sv);
}
- Perl_croak(aTHX_ "%"HEKf" version %"SVf" required--"
- "this is only version %"SVf"", HEKfARG(HvNAME_HEK(pkg)),
+ Perl_croak(aTHX_ "%" HEKf " version %" SVf " required--"
+ "this is only version %" SVf, HEKfARG(HvNAME_HEK(pkg)),
SVfARG(sv_2mortal(req)),
SVfARG(sv_2mortal(sv)));
}