[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:59 UTC 2010


The following commit has been merged in the upstream branch:
commit a23d80aebabf981a34fcca5c8bd2aa5f44ea832d
Author: Markus Roberts <Markus at reality.com>
Date:   Thu Aug 5 22:00:54 2010 -0700

    Fixes #4485 -- single quoted strings should not treat \n as new line
    
    This is the rest of the change for #4303; James and I discussed various
    ways the solution to that ticket needed to be extended but, as neither of us
    committed code, nothing changed.  This is the least implact extension, which
    mimics the behaviour of prior versions.
    
    It leaves open the question: should '\\x' start with a single or double
    backslash?  If, as now, '\\x' starts with a double backslash (i.e. single quote
    is the only escapable characterin single quoted strings) a string ending in a
    backslash can not be represented in a single quoted string.

diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index 24999bf..a25a17e 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,["'"],:ignore_invalid_esapes).first ]
+    [TOKENS[:STRING], lexer.slurpstring(value,["'"],:ignore_invalid_escapes).first ]
   end
 
   DQ_initial_token_types      = {'$' => :DQPRE,'"' => :STRING}
@@ -523,17 +523,17 @@ class Puppet::Parser::Lexer
     str = @scanner.scan_until(/([^\\]|^)[#{terminators}]/) or lex_error "Unclosed quote after '#{last}' in '#{rest}'"
     @line += str.count("\n") # literal carriage returns add to the line count.
     str.gsub!(/\\(.)/) {
-      case ch=$1
-      when 'n'; "\n"
-      when 't'; "\t"
-      when 's'; " "
-      else
-        if escapes.include? ch
-          ch
-        else
-          Puppet.warning "Unrecognised escape sequence '\\#{ch}'#{file && " in file #{file}"}#{line && " at line #{line}"}" unless ignore_invalid_escapes
-          "\\#{ch}"
+      ch = $1
+      if escapes.include? ch
+        case ch
+        when 'n'; "\n"
+        when 't'; "\t"
+        when 's'; " "
+        else      ch
         end
+      else
+        Puppet.warning "Unrecognised escape sequence '\\#{ch}'#{file && " in file #{file}"}#{line && " at line #{line}"}" unless ignore_invalid_escapes
+        "\\#{ch}"
       end
     }
     [ str[0..-2],str[-1,1] ]
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index bcf49ba..7e51423 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -412,6 +412,7 @@ describe Puppet::Parser::Lexer,"when lexing strings" do
     %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 "\n"'}                 => [[:STRING,'single quoted string with an escaped "\n"']],
     %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 '$'"]],

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list