The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 114
MANIFEST 01
META.json 310
META.yml 26
Makefile.PL 17
README 018
lib/UNIVERSAL/require.pm 412
t/require.t 34
t/taint.t 24
9 files changed (This is a version diff) 1676
@@ -1,7 +1,20 @@
 Revision history for Perl module UNIVERSAL::require
 
+0.17 2014-04-19
+    - Check for valid module names. RT#94866 from TOBYINK.
+    - Changed used of die() to croak() RT#23113
+    - Fixed typo in pod (fschlich++)
+
+0.16 2014-02-03
+    - All seems fine with previous dev release
+
+0.15_01 2014-02-03
+    - Added README
+    - Specified min version of perl 5.6.0
+    - Now "use warnings"
+
 0.15 2013-09-28
-    - Hadn't specific meta-spec version 2, so github repo wasn't turning
+    - Hadn't specified meta-spec version 2, so github repo wasn't turning
       up in the metadata.
 
 0.14 2013-08-25
@@ -2,6 +2,7 @@ Changes
 lib/UNIVERSAL/require.pm
 Makefile.PL
 MANIFEST			This list of files
+README
 t/Dummy.pm
 t/require.t
 t/taint.t
@@ -4,7 +4,7 @@
       "Michael G Schwern <schwern@pobox.com>"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.74, CPAN::Meta::Converter version 2.132140",
+   "generated_by" : "ExtUtils::MakeMaker version 6.94, CPAN::Meta::Converter version 2.133380",
    "license" : [
       "perl_5"
    ],
@@ -28,9 +28,16 @@
             "ExtUtils::MakeMaker" : "0"
          }
       },
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
       "runtime" : {
          "requires" : {
-            "Test::More" : "0.47"
+            "Carp" : "0",
+            "Test::More" : "0.47",
+            "perl" : "5.006"
          }
       }
    },
@@ -45,5 +52,5 @@
          "web" : "https://github.com/neilbowers/UNIVERSAL-require"
       }
    },
-   "version" : "0.15"
+   "version" : "0.17"
 }
@@ -4,8 +4,10 @@ author:
   - 'Michael G Schwern <schwern@pobox.com>'
 build_requires:
   ExtUtils::MakeMaker: 0
+configure_requires:
+  ExtUtils::MakeMaker: 0
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.74, CPAN::Meta::Converter version 2.132140'
+generated_by: 'ExtUtils::MakeMaker version 6.94, CPAN::Meta::Converter version 2.133380'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -18,8 +20,10 @@ no_index:
   package:
     - UNIVERSAL
 requires:
+  Carp: 0
   Test::More: 0.47
+  perl: 5.006
 resources:
   license: http://dev.perl.org/licenses/
   repository: git://github.com/neilbowers/UNIVERSAL-require.git
-version: 0.15
+version: 0.17
@@ -20,11 +20,17 @@ WriteMakefile(
     AUTHOR              => 'Michael G Schwern <schwern@pobox.com>',
 
     PREREQ_PM    => {
-        Test::More => 0.47
+        'Test::More' => 0.47,
+        'Carp'       => 0,
     },
 
     ($mm_ver >= 6.31 ? (LICENSE => 'perl') : ()),
 
+    ($mm_ver >= 6.48
+        ? (MIN_PERL_VERSION => 5.006)
+        : ()
+    ),
+
     ($mm_ver <= 6.45 ? () : (META_MERGE => {
         'meta-spec' => { version => 2 },
         resources => {
@@ -0,0 +1,18 @@
+
+    README for Perl module UNIVERSAL::require
+
+This module lets you require other modules where the module
+name is in a variable, something you can't do with the 'require' built-in.
+
+You can read a nicely formatted version of the documentation for
+this module online:
+
+    https://metacpan.org/pod/UNIVERSAL::require
+
+You should be able to install this using your usual method for installing
+modules from CPAN. If you don't have a usual method yet, have a look at:
+
+    http://www.cpan.org/modules/INSTALL.html
+
+This module was written by Michael G Schwern.
+It is now being maintained by Neil Bowers <neilb@cpan.org>
@@ -1,5 +1,5 @@
 package UNIVERSAL::require;
-$UNIVERSAL::require::VERSION = '0.15';
+$UNIVERSAL::require::VERSION = '0.17';
 
 # We do this because UNIVERSAL.pm uses CORE::require().  We're going
 # to put our own require() into UNIVERSAL and that makes an ambiguity.
@@ -8,7 +8,13 @@ BEGIN { require UNIVERSAL }
 
 package UNIVERSAL;
 
+use 5.006;
 use strict;
+use warnings;
+use Carp;
+
+# regexp for valid module name. Lifted from Module::Runtime
+my $module_name_rx = qr/[A-Z_a-z][0-9A-Z_a-z]*(?:::[0-9A-Z_a-z]+)*/;
 
 use vars qw($Level);
 $Level = 0;
@@ -45,7 +51,7 @@ arcane eval() work, you can do this:
 
     $module->require;
 
-It doesn't save you much typing, but it'll make alot more sense to
+It doesn't save you much typing, but it'll make a lot more sense to
 someone who's not a ninth level Perl acolyte.
 
 =head1 Methods
@@ -73,10 +79,12 @@ sub require {
 
     $UNIVERSAL::require::ERROR = '';
 
-    die("UNIVERSAL::require() can only be run as a class method")
+    croak("UNIVERSAL::require() can only be run as a class method")
       if ref $module; 
 
-    die("UNIVERSAL::require() takes no or one arguments") if @_ > 2;
+    croak("invalid module name '$module'") if $module !~ /\A$module_name_rx\z/;
+
+    croak("UNIVERSAL::require() takes no or one arguments") if @_ > 2;
 
     my($call_package, $call_file, $call_line) = caller($Level);
 
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -Tw
 
-use Test::More tests => 16;
+use Test::More tests => 15;
 use_ok "UNIVERSAL::require";
 
 use lib qw(t);
@@ -32,8 +32,9 @@ ok( $Dummy::VERSION,                            '  $VERSION ok' );
 
 
 my $evil = "Dummy; Test::More::fail('this should never be called');";
-ok !$evil->require;
-isnt $@, '';
+eval { $evil->require };
+ok($@ && $@ =~ /invalid module name/,
+   "trying to add trailing code should fail early due to a bad module name");
 
 # make sure $@ and ERROR are set appropriately
 {
@@ -5,6 +5,8 @@ use Test::More tests => 2;
 
 use UNIVERSAL::require;
 
-my $tainted = $0."bogus";
-ok !eval { $tainted->require or die $@};
+my $tainted = $0;
+$tainted =~ s/\A.*\z/bananas/;
+
+ok !eval { $tainted->require or die $@ };
 like $@, '/^Insecure dependency in require /';