]> mj.ucw.cz Git - libucw.git/commitdiff
UCW::Configure: Translate local filenames to "./file"
authorMartin Mares <mj@ucw.cz>
Wed, 22 Feb 2017 15:12:00 +0000 (16:12 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 22 Feb 2017 15:12:00 +0000 (16:12 +0100)
As a security measure, "require" in newer versions of Perl (5.22+)
does not look up files relative to the current directory.

ucw/perl/UCW/Configure.pm

index 5d458adbb63c15e96d1011682eb1286877a0bafd..70647a664bda51441d58cd057d4f3f27d56c0a27 100644 (file)
@@ -112,9 +112,11 @@ sub TestBool($$$) {
 
 sub TryFindFile($) {
        my ($f) = @_;
-       if (-f $f) {
-               return $f;
-       } elsif ($f !~ /^\// && -f (Get("SRCDIR")."/$f")) {
+       if ($f =~ m{^/}) {
+               return (-f $f) ? $f : undef;
+       } elsif (-f $f) {
+               return "./$f";
+       } elsif (-f (Get("SRCDIR")."/$f")) {
                return Get("SRCDIR")."/$f";
        } else {
                return undef;