1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

quote data in regex

People can choose fancy names for vmware objects (e.g. "Datacenter V++"). Make sure that such input doesn't break the regex.
This commit is contained in:
Simon Josi 2013-05-29 14:48:09 +03:00
parent c204dbda76
commit f5eb54d4cf

View file

@ -31,7 +31,7 @@ module Fog
dc_root_folder = dc.vmFolder
# Filter the root path for this datacenter not to be used."
dc_root_folder_path=dc_root_folder.path.map { | id, name | name }.join("/")
paths = path.sub(/^\/?#{dc_root_folder_path}\/?/, '').split('/')
paths = path.sub(/^\/?#{Regex.quote(dc_root_folder_path)}\/?/, '').split('/')
return dc_root_folder if paths.empty?
# Walk the tree resetting the folder pointer as we go