aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/provider/augeas/augeas.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 17879d3..05183e5 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -18,6 +18,7 @@ require 'strscan'
require 'puppet/util'
require 'puppet/util/diff'
require 'puppet/util/package'
+require 'json'
Puppet::Type.type(:augeas).provide(:augeas) do
include Puppet::Util
@@ -280,7 +281,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
when '=='
begin
arg = clause_array.shift
- new_array = eval arg
+ new_array = to_array(arg)
return_value = (values == new_array)
rescue
fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') })
@@ -288,7 +289,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
when '!='
begin
arg = clause_array.shift
- new_array = eval arg
+ new_array = to_array(arg)
return_value = (values != new_array)
rescue
fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') })
@@ -336,7 +337,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
when '=='
begin
arg = clause_array.shift
- new_array = eval arg
+ new_array = to_array(arg)
return_value = (result == new_array)
rescue
fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') })
@@ -344,7 +345,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do
when '!='
begin
arg = clause_array.shift
- new_array = eval arg
+ new_array = to_array(arg)
return_value = (result != new_array)
rescue
fail(_('Invalid array in command: %{cmd}') % { cmd: cmd_array.join(' ') })
@@ -571,4 +572,9 @@ Puppet::Type.type(:augeas).provide(:augeas) do
end
end
# rubocop:enable Style/GuardClause
+
+ def to_array(string)
+ JSON.parse(string.tr("'", '"'))
+ end
+ private :to_array
end