summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-23 11:31:40 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-25 22:24:35 -0700
commit000fd1e83782c70fc9d9b032b52d96800cab2121 (patch)
tree918b7cab06dfb491592bd8908dfeef2fc4add261 /lib/puppet/parser
parent1d494a3104e9794cc09ba27c701ced68a74fa398 (diff)
downloadpuppet-000fd1e83782c70fc9d9b032b52d96800cab2121.tar.gz
puppet-000fd1e83782c70fc9d9b032b52d96800cab2121.tar.xz
puppet-000fd1e83782c70fc9d9b032b52d96800cab2121.zip
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.
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/lexer.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index 1e10ff96c..aa04f17a0 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