You are here: Foswiki>Tasks Web>Item12331 (17 Aug 2015, GeorgeClark)Edit Attach

Item12331: rewriteshebang.pl has troubles with windows slashes

pencil
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: patch
Applies To: Engine
Component: rewriteshebang.pl
Branches:
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
The regular expression requires windows backslashes, but they are then interpreted as escapes when the perl path is tested.

The following patch appears to resolve the issue, accepting either forward or back slashes, and escaping the backslashes.

--- core/tools/rewriteshebang.pl        2012-11-13 16:16:28.948160394 -0500
+++ /home/gac/rewriteshebang.pl 2013-01-06 21:52:09.614190387 -0500
@@ -113,11 +113,11 @@
     $ENV{"PATH"} = ""; # untainted environment for system call
                        # Unix and Windows path matching without spaces to untain
     if ( $new_path =~
-        /(^(\.)?(\/[^\/]+)+(\.exe)?$|^[[:alpha:]]:(\\[^\\]+)+(\.exe)?$|^perl$)/i
+        m#(^(\.)?(\/[^\/]+)+(\.exe)?$|^[[:alpha:]]:(\\[^\\]+)+(\.exe)?$|^[[:alpha:]]:(/[^/]+)+(\.exe)?$|^perl$)#i
       )
     {
-        $new_path = "$1";    # untainted variable
-        @args      = ( "$new_path", "-Mstrict", "-w", '-e "print $];"' );
+        $new_path = $1;    # untainted variable
+        @args      = ( quotemeta($new_path), "-Mstrict", "-w", '-e "print $];"' );
         $new_perlv = qx|@args|;
         if ( $new_perlv < $expect_perlv ) {
             while (1) {

ItemTemplate edit

Summary rewriteshebang.pl has troubles with windows slashes
ReportedBy GeorgeClark
Codebase 1.1.6, trunk
SVN Range
AppliesTo Engine
Component rewriteshebang.pl
Priority Normal
CurrentState Confirmed
WaitingFor
Checkins
TargetRelease patch
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release01x01Checkins
Topic revision: r2 - 17 Aug 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy