Item12331: rewriteshebang.pl has troubles with windows slashes
Priority: Normal
Current State: Confirmed
Released In: n/a
Target Release: patch
Applies To: Engine
Component: rewriteshebang.pl
Branches:
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) {