throw an exception when whitespace is found within an alias keyword
This commit is contained in:
parent
57419fd12c
commit
f46ebf5240
|
@ -57,6 +57,9 @@ module Vagrant
|
||||||
# The directory where temporary files for Vagrant go.
|
# The directory where temporary files for Vagrant go.
|
||||||
attr_reader :tmp_path
|
attr_reader :tmp_path
|
||||||
|
|
||||||
|
# File where command line aliases go.
|
||||||
|
attr_reader :aliases_path
|
||||||
|
|
||||||
# The directory where boxes are stored.
|
# The directory where boxes are stored.
|
||||||
attr_reader :boxes_path
|
attr_reader :boxes_path
|
||||||
|
|
||||||
|
@ -123,6 +126,7 @@ module Vagrant
|
||||||
@data_dir = @home_path.join("data")
|
@data_dir = @home_path.join("data")
|
||||||
@gems_path = Vagrant::Bundler.instance.plugin_gem_path
|
@gems_path = Vagrant::Bundler.instance.plugin_gem_path
|
||||||
@tmp_path = @home_path.join("tmp")
|
@tmp_path = @home_path.join("tmp")
|
||||||
|
@aliases_path = @home_path.join("aliases")
|
||||||
@machine_index_dir = @data_dir.join("machine-index")
|
@machine_index_dir = @data_dir.join("machine-index")
|
||||||
|
|
||||||
# Prepare the directories
|
# Prepare the directories
|
||||||
|
|
|
@ -108,6 +108,10 @@ module Vagrant
|
||||||
error_key(:active_machine_with_different_provider)
|
error_key(:active_machine_with_different_provider)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class AliasInvalidError < VagrantError
|
||||||
|
error_key(:alias_invalid_error)
|
||||||
|
end
|
||||||
|
|
||||||
class BatchMultiError < VagrantError
|
class BatchMultiError < VagrantError
|
||||||
error_key(:batch_multi_error)
|
error_key(:batch_multi_error)
|
||||||
end
|
end
|
||||||
|
|
|
@ -378,6 +378,12 @@ en:
|
||||||
Machine name: %{name}
|
Machine name: %{name}
|
||||||
Active provider: %{active_provider}
|
Active provider: %{active_provider}
|
||||||
Requested provider: %{requested_provider}
|
Requested provider: %{requested_provider}
|
||||||
|
alias_invalid_error: |-
|
||||||
|
The defined alias is not valid. Please review the information below
|
||||||
|
to help resolve the issue:
|
||||||
|
|
||||||
|
Alias: %{alias}
|
||||||
|
Message: %{message}
|
||||||
batch_multi_error: |-
|
batch_multi_error: |-
|
||||||
An error occurred while executing multiple actions in parallel.
|
An error occurred while executing multiple actions in parallel.
|
||||||
Any errors that occurred are shown below.
|
Any errors that occurred are shown below.
|
||||||
|
|
|
@ -25,6 +25,18 @@ describe Vagrant::Alias do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "raises an error on invalid keywords" do
|
||||||
|
keywords = [
|
||||||
|
"keyword with a space = command",
|
||||||
|
"keyword\twith a tab = command",
|
||||||
|
"keyword\nwith a newline = command",
|
||||||
|
]
|
||||||
|
|
||||||
|
keywords.each do |keyword|
|
||||||
|
expect { interpreter.interpret(keyword) }.to raise_error(Vagrant::Errors::AliasInvalidError)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "properly interprets a simple alias" do
|
it "properly interprets a simple alias" do
|
||||||
keyword, command = interpreter.interpret("keyword=command")
|
keyword, command = interpreter.interpret("keyword=command")
|
||||||
|
|
||||||
|
@ -45,5 +57,12 @@ describe Vagrant::Alias do
|
||||||
expect(keyword).to eq("keyword")
|
expect(keyword).to eq("keyword")
|
||||||
expect(command).to eq("command = command")
|
expect(command).to eq("command = command")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows keywords with non-alpha-numeric characters" do
|
||||||
|
keyword, command = interpreter.interpret("keyword! = command")
|
||||||
|
|
||||||
|
expect(keyword).to eq("keyword!")
|
||||||
|
expect(command).to eq("command")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue