From 3d009b4dc5dfe1148536f10a07af551eed23bbef Mon Sep 17 00:00:00 2001 From: George Clark Date: Thu, 4 Sep 2014 09:44:42 -0400 Subject: [PATCH] Item12952: Use File::Basename to parse Thanks WillNorris for the point-out. --- core/lib/Foswiki.pm | 3 ++- core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm index da2886ff10..dfd13b51f4 100644 --- a/core/lib/Foswiki.pm +++ b/core/lib/Foswiki.pm @@ -46,6 +46,7 @@ use warnings; use Assert; use Cwd qw( abs_path ); use Error qw( :try ); +use File::Basename; use File::Spec (); use Monitor (); use CGI (); # Always required to get html generation tags; @@ -384,7 +385,7 @@ BEGIN { "AUTOCONFIG: Found Bin dir: $bin, Script name: $script using FindBin\n" if (TRAUTO); - $Foswiki::cfg{ScriptSuffix} = ( $script =~ /(\.[^.]*)$/ ) ? $1 : ''; + $Foswiki::cfg{ScriptSuffix} = ( fileparse( $script, qr/\.[^.]*/ ) )[2]; print STDERR "AUTOCONFIG: Found SCRIPT SUFFIX $Foswiki::cfg{ScriptSuffix} \n" if ( TRAUTO && $Foswiki::cfg{ScriptSuffix} ); diff --git a/core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm b/core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm index 84f23add3a..75eaac4208 100755 --- a/core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm +++ b/core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm @@ -4,21 +4,19 @@ package Foswiki::Configure::Checkers::ScriptSuffix; use strict; use warnings; +use File::Basename; use Foswiki::Configure::Checker (); our @ISA = ('Foswiki::Configure::Checker'); sub check_current_value { my ( $this, $reporter ) = @_; - # SMELL: On FreeBSD, $0 includes the full path. - # Don't allow any path components to disrupt the suffix - my $currentSuffix = ( $0 =~ /(\.[^.\/]*?)$/ ) ? $1 : ''; - + my $currentSuffix = ( fileparse( $0, qr/\.[^.]*/ ) )[2]; my $expectedSuffix = $Foswiki::cfg{ScriptSuffix} || ''; if ( $currentSuffix ne $expectedSuffix ) { $reporter->WARN( <