Issue #10885 has been updated by Josh Cooper.

Status changed from Accepted to In Topic Branch Pending Review
Branch set to https://github.com/puppetlabs/facter/pull/100


----------------------------------------
Bug #10885: Malformed facter.bat when ruby path contains regexp 
backreference-like sequences on Windows
https://projects.puppetlabs.com/issues/10885

Author: Josh Cooper
Status: In Topic Branch Pending Review
Priority: Normal
Assignee: Josh Cooper
Category: 
Target version: 1.6.x
Keywords: windows
Branch: https://github.com/puppetlabs/facter/pull/100
Affected Facter version: 1.6.0


If your ruby's install dir happens to contain a numeric value following a 
backslash, e.g. `c:\ruby\1.8.7`, the install.rb script mistakes that for a 
regexp backreference and corrupts the resulting facter.bat.

In install.rb, the values of `ruby` and `cwn` are used as replacement strings 
in calls to gsub. 

<pre>
      cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" 
}).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } )
</pre>

But since potential 'backreferences', i.e. \1, are not escaped, the calls to 
gsub attempt to replace them with the corresponding capture group, but since 
there are none, the 'backreference' is stripped, corrupting the batch file.

<pre>
@echo off
if "%OS%"=="Windows_NT" goto WinNT
c:\ruby.8.7\bin\ruby -x "c:\ruby.8.7\bin\facter" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto done
:WinNT
c:\ruby.8.7\bin\ruby -x "c:\ruby.8.7\bin\facter" %*
goto done
:done
</pre>

This is the same issue that commit:d9a693dc4431430fcfdc3ae15bee8b4a0985868f 
attempted to fix for puppet, but resulted in #10799


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to