diff --git a/acceptance/tests/resource/registry/should_manage_values.rb b/acceptance/tests/resource/registry/should_manage_values.rb index 657cb8e0..667fd2b8 100644 --- a/acceptance/tests/resource/registry/should_manage_values.rb +++ b/acceptance/tests/resource/registry/should_manage_values.rb @@ -184,7 +184,7 @@ class phase1 { # Binary Values registry_value { '#{keypath}\\SubKey1\\ValueBinary1': type => binary, - data => "0${::fact_phase}", + data => "${::fact_phase}", } registry_value { '#{keypath}\\SubKey1\\ValueBinary2': type => binary, diff --git a/lib/puppet/type/registry_value.rb b/lib/puppet/type/registry_value.rb index 4ae229c5..556cba3d 100644 --- a/lib/puppet/type/registry_value.rb +++ b/lib/puppet/type/registry_value.rb @@ -16,10 +16,10 @@ **Autorequires:** Any parent registry key managed by Puppet will be autorequired. -EOT + EOT def self.title_patterns - [ [ /^(.*?)\Z/m, [ [ :path, lambda{|x| x} ] ] ] ] + [[/^(.*?)\Z/m, [[:path, lambda { |x| x }]]]] end ensurable @@ -84,6 +84,9 @@ def self.title_patterns fail("The data must be a valid QWORD: #{value}") unless val and (val.abs >> 64) <= 0 val when :binary + if (value.respond_to?(:length) && value.length == 1) || (value.kind_of?(Integer) && value <= 9) + value = "0#{value}" + end unless value.match(/^([a-f\d]{2} ?)*$/i) fail("The data must be a hex encoded string of the form: '00 01 02 ...'") end diff --git a/spec/unit/puppet/type/registry_value_spec.rb b/spec/unit/puppet/type/registry_value_spec.rb index 138a17bb..03deb1c7 100644 --- a/spec/unit/puppet/type/registry_value_spec.rb +++ b/spec/unit/puppet/type/registry_value_spec.rb @@ -136,6 +136,12 @@ value[:data] = data end end + [9,'1','A'].each do |data| + it "should accept '#{data}' and have a leading zero" do + value[:type] = :binary + value[:data] = data + end + end ["\040\040", 'foobar', :true].each do |data| it "should reject '#{data}'" do