[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.1rc1-141-gcdb2b90
Markus Roberts
Markus at reality.com
Mon Aug 16 12:48:17 UTC 2010
The following commit has been merged in the upstream branch:
commit 000fd1e83782c70fc9d9b032b52d96800cab2121
Author: Markus Roberts <Markus at reality.com>
Date: Fri Jul 23 11:31:40 2010 -0700
Fix for #4303 -- reverting to old escaping in '-strings
Single quoted used to allow escape on single quotes and pass all other
characters through without comment; now the do again.
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index 1e10ff9..aa04f17 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -221,7 +221,7 @@ class Puppet::Parser::Lexer
TOKENS.add_token :RETURN, "\n", :skip => true, :incr_line => true, :skip_text => true
TOKENS.add_token :SQUOTE, "'" do |lexer, value|
- [TOKENS[:STRING], lexer.slurpstring(value).first ]
+ [TOKENS[:STRING], lexer.slurpstring(value,["'"],:ignore_invalid_esapes).first ]
end
DQ_initial_token_types = {'$' => :DQPRE,'"' => :STRING}
@@ -517,8 +517,7 @@ class Puppet::Parser::Lexer
# we've encountered the start of a string...
# slurp in the rest of the string and return it
- Valid_escapes_in_strings = %w{ \\ $ ' " n t s }+["\n"]
- def slurpstring(terminators)
+ def slurpstring(terminators,escapes=%w{ \\ $ ' " n t s }+["\n"],ignore_invalid_escapes=false)
# we search for the next quote that isn't preceded by a
# backslash; the caret is there to match empty strings
str = @scanner.scan_until(/([^\\]|^)[#{terminators}]/) or lex_error "Unclosed quote after '#{last}' in '#{rest}'"
@@ -529,10 +528,10 @@ class Puppet::Parser::Lexer
when 't'; "\t"
when 's'; " "
else
- if Valid_escapes_in_strings.include? ch and not (ch == '"' and terminators == "'")
+ if escapes.include? ch
ch
else
- Puppet.warning "Unrecognised escape sequence '\\#{ch}'#{file && " in file #{file}"}#{line && " at line #{line}"}"
+ Puppet.warning "Unrecognised escape sequence '\\#{ch}'#{file && " in file #{file}"}#{line && " at line #{line}"}" unless ignore_invalid_escapes
"\\#{ch}"
end
end
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index d3d2a0a..a85d1b2 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -410,6 +410,9 @@ describe Puppet::Parser::Lexer,"when lexing strings" do
%q{'single quoted string')} => [[:STRING,'single quoted string']],
%q{"double quoted string"} => [[:STRING,'double quoted string']],
%q{'single quoted string with an escaped "\\'"'} => [[:STRING,'single quoted string with an escaped "\'"']],
+ %q{'single quoted string with an escaped "\$"'} => [[:STRING,'single quoted string with an escaped "\$"']],
+ %q{'single quoted string with an escaped "\."'} => [[:STRING,'single quoted string with an escaped "\."']],
+ %q{'single quoted string with an escaped "\\\\"'} => [[:STRING,'single quoted string with an escaped "\\\\"']],
%q{"string with an escaped '\\"'"} => [[:STRING,"string with an escaped '\"'"]],
%q{"string with an escaped '\\$'"} => [[:STRING,"string with an escaped '$'"]],
%q{"string with $v (but no braces)"} => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' (but no braces)']],
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list