]> gitweb.fluxo.info Git - puppet-mailalias_core.git/commitdiff
(MODULES-7202) fixes comma handling in value
authorCiprian Badescu <ciprian.badescu@puppet.com>
Fri, 7 Feb 2020 15:57:42 +0000 (17:57 +0200)
committerCiprian Badescu <ciprian.badescu@puppet.com>
Mon, 10 Feb 2020 09:03:58 +0000 (11:03 +0200)
regular expression that we use to separate values by comma was updated
to take into account only commas outside quoted strings

lib/puppet/provider/mailalias/aliases.rb
spec/fixtures/integration/provider/mailalias/aliases/test1

index 7ec30b1a16556dacb4f60de71110fe7676a052fb..16f41addbcf478d53406606507d9226ce04581ec 100644 (file)
@@ -15,7 +15,7 @@ Puppet::Type.type(:mailalias).provide(
   record_line :aliases, fields: ['name', 'recipient'], separator: %r{\s*:\s*}, block_eval: :instance do
     def post_parse(record)
       if record[:recipient]
-        record[:recipient] = record[:recipient].split(%r{\s*,\s*}).map { |d| d.gsub(%r{^['"]|['"]$}, '') }
+        record[:recipient] = record[:recipient].split(%r{\s*,\s*(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)}).map { |d| d.gsub(%r{^['"]|['"]$}, '') }
       end
       record
     end
index a69be8a2f339da01985bb4b7da028ef807ff9535..342239dc24ed9666d5fdbb16a1777de509798fcb 100644 (file)
@@ -26,6 +26,7 @@ decode:     root
 # Other tests
 anothertest: "|/path/to/rt-mailgate --queue 'another test' --action correspond --url http://my.com/"
 test: "|/path/to/rt-mailgate --queue 'test' --action correspond --url http://my.com/"
+commas_in_command_test: "|/path/to/rt-mailgate --queue 'test' --action correspond --url http://my.com/ --projects projecta,projectb"
 
 # Included file
 incfile: :include: /tmp/somefile