Skip to content

Commit de6dc5f

Browse files
tja523petergmurphy
authored andcommitted
match section names containing prefix character
Currently sections with names including the prefix (normally [) can be created by this provider, but they are then not matched by the regex, meaning puppet will create a new section (with the same name) every time it runs. Fix that by allowing the section prefix in the section name. Any line that starts with the correct prefix (normally [) and ends with the correct suffix (normally ]) is treated as a valid section header, regardless of what is between them. This is needed for splunk inputs.conf file where regexes, including square brackets, are allowed inside the section name.
1 parent a0ef2bd commit de6dc5f

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

lib/puppet/util/ini_file.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,9 @@ def initialize(path, key_val_separator = ' = ', section_prefix = '[', section_su
3131

3232
def section_regex
3333
# Only put in prefix/suffix if they exist
34-
# Also, if the prefix is '', the negated
35-
# set match should be a match all instead.
3634
r_string = '^\s*'
3735
r_string += Regexp.escape(@section_prefix)
38-
r_string += '('
39-
if @section_prefix != ''
40-
r_string += '[^'
41-
r_string += Regexp.escape(@section_prefix)
42-
r_string += ']'
43-
else
44-
r_string += '.'
45-
end
46-
r_string += '*)'
36+
r_string += '(.*)'
4737
r_string += Regexp.escape(@section_suffix)
4838
r_string += '\s*$'
4939
%r{#{r_string}}

0 commit comments

Comments
 (0)