From 45ae5b4a9ced26dfcd3e324391f9a26cb02bf93d Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Mon, 18 Jul 2011 22:44:10 -0700 Subject: (#8268) Require windows drive letters in absolute file paths When testing whether a file path is absolute, the regexp was only handling POSIX style file paths. This commit requires Windows style file paths to start with a drive letter. A future commit will refacter the various places we do path validation to support both Windows drive letters and UNC paths. Reviewed-by: Jacob Helwig --- lib/puppet/node/environment.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/puppet/node') diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index dc631979e..96fdc3c1e 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -136,14 +136,15 @@ class Puppet::Node::Environment end def validate_dirs(dirs) + dir_regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ : /^#{File::SEPARATOR}/ dirs.collect do |dir| - if dir !~ /^#{File::SEPARATOR}/ + if dir !~ dir_regex File.join(Dir.getwd, dir) else dir end end.find_all do |p| - p =~ /^#{File::SEPARATOR}/ && FileTest.directory?(p) + p =~ dir_regex && FileTest.directory?(p) end end -- cgit