From f5eb54d4cf7727310940c53321d8246c5e9be145 Mon Sep 17 00:00:00 2001 From: Simon Josi Date: Wed, 29 May 2013 14:48:09 +0300 Subject: [PATCH] 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. --- lib/fog/vsphere/requests/compute/get_folder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/vsphere/requests/compute/get_folder.rb b/lib/fog/vsphere/requests/compute/get_folder.rb index 733d44806..2b5da257a 100644 --- a/lib/fog/vsphere/requests/compute/get_folder.rb +++ b/lib/fog/vsphere/requests/compute/get_folder.rb @@ -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