Skip to content

Commit a09bfef

Browse files
author
Morgan Haskel
committed
Merge pull request #171 from misterdorm/bug1599
MODULES-1599 Match only on space and tab whitespace after k/v separator
2 parents e132445 + c784253 commit a09bfef

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/puppet/util/ini_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(path, key_val_separator = ' = ', section_prefix = '[', section_su
1313
@section_suffix = section_suffix
1414

1515
@@SECTION_REGEX = section_regex
16-
@@SETTING_REGEX = /^(\s*)([^#;\s]|[^#;\s].*?[^\s#{k_v_s}])(\s*#{k_v_s}\s*)(.*)\s*$/
16+
@@SETTING_REGEX = /^(\s*)([^#;\s]|[^#;\s].*?[^\s#{k_v_s}])(\s*#{k_v_s}[ \t]*)(.*)\s*$/
1717
@@COMMENTED_SETTING_REGEX = /^(\s*)[#;]+(\s*)(.*?[^\s#{k_v_s}])(\s*#{k_v_s}[ \t]*)(.*)\s*$/
1818

1919
@path = path

spec/acceptance/ini_setting_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,40 @@
7272
it_behaves_like 'has_content', "#{tmpdir}/ini_setting.ini", pp, /four = five\n\n\[one\]\ntwo = three/
7373
end
7474

75+
context '=> present for global and section (from previous blank value)' do
76+
before :all do
77+
if fact('osfamily') == 'Darwin'
78+
shell("echo \"four =[one]\ntwo =\" > #{tmpdir}/ini_setting.ini")
79+
else
80+
shell("echo -e \"four =\n[one]\ntwo =\" > #{tmpdir}/ini_setting.ini")
81+
end
82+
end
83+
84+
pp = <<-EOS
85+
ini_setting { 'ensure => present for section':
86+
ensure => present,
87+
path => "#{tmpdir}/ini_setting.ini",
88+
section => 'one',
89+
setting => 'two',
90+
value => 'three',
91+
}
92+
ini_setting { 'ensure => present for global':
93+
ensure => present,
94+
path => "#{tmpdir}/ini_setting.ini",
95+
section => '',
96+
setting => 'four',
97+
value => 'five',
98+
}
99+
EOS
100+
101+
it 'applies the manifest twice' do
102+
apply_manifest(pp, :catch_failures => true)
103+
apply_manifest(pp, :catch_changes => true)
104+
end
105+
106+
it_behaves_like 'has_content', "#{tmpdir}/ini_setting.ini", pp, /four = five\n\n\[one\]\ntwo = three/
107+
end
108+
75109
context '=> absent for key/value' do
76110
before :all do
77111
if fact('osfamily') == 'Darwin'

0 commit comments

Comments
 (0)