puppetlabs/facter — pull request #99 by joshcooper (2011-11-15 21:23:39+00:00)
Title: #10799 Replacement string backreferences are not escaped

Previously, we were substituting occurrences of and
in the Windows batch wrapper scripts with the corresponding
paths. However,the gsub replacement string was not escaped, so if a
path contained something that looked like a backreference,
e.g. foo\1bar, the gsub would strip out the backreference (since there
were no capture groups). As a result, the paths would be corrupted.

This commit eliminates the need for gsub, since paths can contain
other characters that have special meaning in a regexp.

It also writes the bat file in 'text' mode so that the resulting file
has '\r\n' line endings.