Skip to content

Commit

Permalink
Merge pull request #457 from tja523/fix-section-regex
Browse files Browse the repository at this point in the history
match section names containing prefix character (normally [)
  • Loading branch information
chelnak authored May 23, 2022
2 parents 2c1406f + de6dc5f commit 9cfa30b
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions lib/puppet/util/ini_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,9 @@ def initialize(path, key_val_separator = ' = ', section_prefix = '[', section_su

def section_regex
# Only put in prefix/suffix if they exist
# Also, if the prefix is '', the negated
# set match should be a match all instead.
r_string = '^\s*'
r_string += Regexp.escape(@section_prefix)
r_string += '('
if @section_prefix != ''
r_string += '[^'
r_string += Regexp.escape(@section_prefix)
r_string += ']'
else
r_string += '.'
end
r_string += '*)'
r_string += '(.*)'
r_string += Regexp.escape(@section_suffix)
r_string += '\s*$'
%r{#{r_string}}
Expand Down

0 comments on commit 9cfa30b

Please sign in to comment.