Issue #8650 has been reported by Josh Cooper.
----------------------------------------
Bug #8650: Refactor path validation
https://projects.puppetlabs.com/issues/8650
Author: Josh Cooper
Status: Accepted
Priority: Normal
Assignee:
Category: windows
Target version: Telly
Affected Puppet version:
Keywords:
Branch:
There are many places where paths are validated (see below), but the logic is
not consistent for Windows platforms. Specifically:
* On Windows, both File::SEPARATOR '/' and File::ALT_SEPARATOR '\' are valid
separators and may appear within the same path. For example, Dir.getwd()
returns paths with backslashes, which are often joined with paths that contain
forward slashes. See lib/puppet/node/environment.rb
* Windows absolute paths must start with a prefix. This is either a drive
letter followed by ':' and '\' or '/'. For UNC paths, the prefix is "\\\\",
followed by the hostname and share name. This leads to some validation issues,
such as trailing slashes can be stripped (C:\foo\ == C:\foo), unless the path
refers to the root of the path (C:\ != C:). Also duplicate slashes can be
collapsed (C:\foo\\\\bar == C:\foo\bar), except when referring to UNC paths
(\\\\foo\bar != \foo\bar).
* We currently use regex's to validate paths, but since File::ALT_SEPARATOR is
backslash, it must be escaped if used in a regex. This is true on unix, since \
can appear in a filename.
We need to create utility methods to test whether a path is an absolute path.
On Unix, it should do what it does currently, ensure the path starts with
File::SEPARATOR. On Windows, it needs to take into account the issues above.
The places that currently do checks like the following should call the utility
method instead:
<pre>
regex = Puppet.features.microsoft_windows? ? /^[A-Za-z]:#{File::SEPARATOR}/ :
/^#{File::SEPARATOR}/
raise ArgumentError.new("Paths must be fully qualified") unless path =~
/^#{::File::SEPARATOR}/
next if win32 and path =~ %r{^(?:[a-zA-Z]:)?#{absolute}}
</pre>
The spec tests need to be updated to take these variations into account,
especially spec/shared_behaviors/path_parameters.rb
--
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.