summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/ast/leaf.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2010-03-03 20:35:46 +0100
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitb581c2348e784ce5d857a4c1c0686399b87cc13f (patch)
treed85c3e9d79d99c3ad9a2a679fa4d8666e74a2158 /lib/puppet/parser/ast/leaf.rb
parent490a03d55e57a5a54202207b44eb406dda4c8c65 (diff)
downloadpuppet-b581c2348e784ce5d857a4c1c0686399b87cc13f.tar.gz
puppet-b581c2348e784ce5d857a4c1c0686399b87cc13f.tar.xz
puppet-b581c2348e784ce5d857a4c1c0686399b87cc13f.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/ast/leaf.rb')
-rw-r--r--lib/puppet/parser/ast/leaf.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index 0f427ef37..4ad1f9ff3 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -13,12 +13,12 @@ class Puppet::Parser::AST
# evaluate ourselves, and match
def evaluate_match(value, scope, options = {})
obj = self.safeevaluate(scope)
- if ! options[:sensitive] && obj.respond_to?(:downcase)
- obj = obj.downcase
+ if options[:sensitive]
+ obj = obj.downcase if obj.respond_to?(:downcase)
+ value = value.downcase if value.respond_to?(:downcase)
end
# "" == undef for case/selector/if
- return true if obj == "" and value == :undef
- obj == value
+ obj == value or (obj == "" and value == :undef)
end
def match(value)