Sanitize folder names for default virtualbox name [GH-1223]

This commit is contained in:
Mitchell Hashimoto 2013-01-30 22:17:10 -08:00
parent 7fe19d3a11
commit 76ca35a095
2 changed files with 7 additions and 2 deletions

View File

@ -79,6 +79,7 @@ IMPROVEMENTS / BUG FIXES:
using SCP to upload files. [GH-924]
- Box adding doesn't use `/tmp` anymore which can avoid some cross-device
copy issues. [GH-1199]
- Vagrant works properly in folders with strange characters. [GH-1223]
## 1.0.6 (December 21, 2012)

View File

@ -10,8 +10,12 @@ module VagrantPlugins
end
def call(env)
@logger.info("Setting the default name of the VM")
name = env[:root_path].basename.to_s + "_#{Time.now.to_i}"
# Figure out the name and sanitize the default
prefix = env[:root_path].basename.to_s
prefix.gsub!(/[^-a-z0-9_]/i, "")
name = prefix + "_#{Time.now.to_i}"
@logger.info("Setting the default name of the VM: #{name}")
env[:machine].provider.driver.set_name(name)
@app.call(env)