diff --git a/lib/puppet/provider/asadmin.rb b/lib/puppet/provider/asadmin.rb index b36e7e2..ee65b22 100644 --- a/lib/puppet/provider/asadmin.rb +++ b/lib/puppet/provider/asadmin.rb @@ -51,8 +51,8 @@ def asadmin_exec(passed_args) end def escape(value) - # Add three backslashes to escape the colon - return value.gsub(/:/) { '\\:' } + # Add backslashes to colons and already-escaped qoutes. + return value.gsub(/:/){ '\\:' }.gsub(/\"/) { '\\\\"' } end # def exists? diff --git a/lib/puppet/provider/jvmoption/asadmin.rb b/lib/puppet/provider/jvmoption/asadmin.rb index a491965..ac64299 100644 --- a/lib/puppet/provider/jvmoption/asadmin.rb +++ b/lib/puppet/provider/jvmoption/asadmin.rb @@ -27,8 +27,9 @@ def exists? args << "list-jvm-options" args << "--target" << @resource[:target] if @resource[:target] - #Remove escaped semi-colons for matching the jvm option name + #Remove escaped semi-colons and qoutes for matching the jvm option name name = @resource[:name].sub "\\:" , ":" + name = name.gsub "\\\"" , "\"" asadmin_exec(args).each do |line| line.sub!(/-XX: ([^\ ]+)/, '-XX:+\1') diff --git a/lib/puppet/type/jvmoption.rb b/lib/puppet/type/jvmoption.rb index 57736a6..5831526 100644 --- a/lib/puppet/type/jvmoption.rb +++ b/lib/puppet/type/jvmoption.rb @@ -10,8 +10,8 @@ isnamevar validate do |value| - unless value =~ /^-(?:[\w\-.:\\+])+(?:=[\w\-\.\/${}\\:]+)?$/ - raise ArgumentError, "%s is not a valid JVM option." % value + unless value =~ /^-(?:[\w\-.:\\+])+(?:=[\w\-\.\/${}\\:]+|=\\\".*\\\")?$/ + raise ArgumentError, "%s is not a valid JVM option." % value end end end diff --git a/spec/unit/puppet/type/jvmoption_spec.rb b/spec/unit/puppet/type/jvmoption_spec.rb index e27c150..53a66ee 100644 --- a/spec/unit/puppet/type/jvmoption_spec.rb +++ b/spec/unit/puppet/type/jvmoption_spec.rb @@ -52,8 +52,13 @@ described_class.new(:option => '-Dtest.url=http\:www.gmail.com', :ensure => :present)[:option].should == '-Dtest.url=http\:www.gmail.com' end - it "should not support spaces" do + it "should not support spaces in the option name" do expect { described_class.new(:option => '-X Option', :ensure => :present) }.to raise_error(Puppet::Error, /-X Option is not a valid JVM option/) + expect { described_class.new(:option => '-X Option=value', :ensure => :present) }.to raise_error(Puppet::Error, /-X Option=value is not a valid JVM option/) + end + + it "should support spaces contained within escaped double-qoutes in an option value" do + described_class.new(:option => '-XOption=\"a value\"', :ensure => :present)[:option].should == '-XOption=\"a value\"' end end