[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5
James Turnbull
james at lovedthanlost.net
Tue Oct 27 17:05:45 UTC 2009
The following commit has been merged in the upstream branch:
commit 6551e86a03f5fa1f499386c96faa4587bdfac24e
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date: Mon Sep 21 22:48:30 2009 +0200
Fix #2664 - Mathematic expressions mis-lexed as Regex
This is not the real fix. It is just an hot-fix to limit
the issue.
The issue is that the lexer regexes have precedences over simple
'/' (divide).
In the following expression:
$var = 4096 / 4
$var2 = "/tmp/file"
The / 4... part is mis-lexed as a regex instead of a mathematical
expression.
The current fix limits regex to one-line.
Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index e027a69..0db6c22 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -171,7 +171,7 @@ class Puppet::Parser::Lexer
[self,value]
end
- TOKENS.add_token :REGEX, %r{/[^/]*/} do |lexer, value|
+ TOKENS.add_token :REGEX, %r{/[^/\n]*/} do |lexer, value|
# Make sure we haven't matched an escaped /
while value[-2..-2] == '\\'
other = lexer.scan_until(%r{/})
diff --git a/spec/unit/parser/lexer.rb b/spec/unit/parser/lexer.rb
index 1c3e91b..3c73ca9 100755
--- a/spec/unit/parser/lexer.rb
+++ b/spec/unit/parser/lexer.rb
@@ -460,6 +460,10 @@ describe Puppet::Parser::Lexer::TOKENS[:REGEX] do
@token.regex.should =~ '/this is a regex/'
end
+ it 'should not match if there is \n in the regex' do
+ @token.regex.should_not =~ "/this is \n a regex/"
+ end
+
describe "when including escaped slashes" do
before { @lexer = Puppet::Parser::Lexer.new }
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list