summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2010-03-03 20:35:46 +0100
committerJames Turnbull <james@lovedthanlost.net>2010-03-25 11:59:12 +1100
commit4b2b9ebfb566776373f48357e9df61a88b410faa (patch)
tree53eda77f4d1d3e15a5129728ba97a5f10358146e /lib/puppet/parser
parent19863c07f983ec181fb81c797ee8b9c8d335e18c (diff)
downloadpuppet-4b2b9ebfb566776373f48357e9df61a88b410faa.tar.gz
puppet-4b2b9ebfb566776373f48357e9df61a88b410faa.tar.xz
puppet-4b2b9ebfb566776373f48357e9df61a88b410faa.zip
Fix #3229 - use original value in case/selector regex matching
The issue is that case/selectors are downcasing the value before it is compared to the options. Unfortunately regex are matching in a case sensitive way, which would make the following manifest fail: $var = "CaseSensitive" case $var { /CaseSensitive/: { notice("worked") } default: { fail "miserably" } } This patch fixes the issue by making sure the regexp match is done one the original (not downcased) value, but still doing a case sensitive match. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/ast/casestatement.rb4
-rw-r--r--lib/puppet/parser/ast/leaf.rb1
-rw-r--r--lib/puppet/parser/ast/selector.rb2
3 files changed, 2 insertions, 5 deletions
diff --git a/lib/puppet/parser/ast/casestatement.rb b/lib/puppet/parser/ast/casestatement.rb
index 25b0fc691..64298cac3 100644
--- a/lib/puppet/parser/ast/casestatement.rb
+++ b/lib/puppet/parser/ast/casestatement.rb
@@ -12,8 +12,6 @@ class Puppet::Parser::AST
# the first option that matches.
def evaluate(scope)
value = @test.safeevaluate(scope)
- sensitive = Puppet[:casesensitive]
- value = value.downcase if ! sensitive and value.respond_to?(:downcase)
retvalue = nil
found = false
@@ -22,7 +20,7 @@ class Puppet::Parser::AST
default = nil
@options.each do |option|
option.eachopt do |opt|
- return option.safeevaluate(scope) if opt.evaluate_match(value, scope, :file => file, :line => line, :sensitive => sensitive)
+ return option.safeevaluate(scope) if opt.evaluate_match(value, scope, :file => file, :line => line, :sensitive => Puppet[:casesensitive])
end
default = option if option.default?
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index c8ac6f7e3..ee7ee02e8 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -16,6 +16,7 @@ class Puppet::Parser::AST
if ! options[:sensitive] && obj.respond_to?(:downcase)
obj = obj.downcase
end
+ value = value.downcase if not options[:sensitive] and value.respond_to?(:downcase)
obj == value
end
diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb
index 84bc2a74a..ce834b63b 100644
--- a/lib/puppet/parser/ast/selector.rb
+++ b/lib/puppet/parser/ast/selector.rb
@@ -17,8 +17,6 @@ class Puppet::Parser::AST
sensitive = Puppet[:casesensitive]
- paramvalue = paramvalue.downcase if not sensitive and paramvalue.respond_to?(:downcase)
-
default = nil
unless @values.instance_of? AST::ASTArray or @values.instance_of? Array