diff --git a/spec/parser.js b/spec/parser.js index 93ad216..a45197e 100644 --- a/spec/parser.js +++ b/spec/parser.js @@ -538,4 +538,9 @@ describe('parser', function () { }) ); }); + + it('GH2059 - should evaluate null characters', function() { + const nul = String.fromCharCode(0); + equalsAst('Hello ' + nul + ' {{name}}', "CONTENT[ 'Hello " + nul + " ' ]\n{{ p%name }}" ) + }) }); diff --git a/src/handlebars.l b/src/handlebars.l index c23971f..36ea519 100644 --- a/src/handlebars.l +++ b/src/handlebars.l @@ -28,7 +28,7 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD} %% -[^\x00]*?/("{{") { +[\s\S]*?/("{{") { if(yytext.slice(-2) === "\\\\") { strip(0,1); this.begin("mu"); @@ -41,10 +41,10 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD} if(yytext) return 'CONTENT'; } -[^\x00]+ return 'CONTENT'; +[\s\S]+ return 'CONTENT'; // marks CONTENT up to the next mustache or escaped mustache -[^\x00]{2,}?/("{{"|"\\{{"|"\\\\{{"|<>) { +[\s\S]{2,}?/("{{"|"\\{{"|"\\\\{{"|<>) { this.popState(); return 'CONTENT'; } @@ -63,7 +63,7 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD} return 'END_RAW_BLOCK'; } } -[^\x00]+?/("{{{{") { return 'CONTENT'; } +[\s\S]+?/("{{{{") { return 'CONTENT'; } [\s\S]*?"--"{RIGHT_STRIP}?"}}" { this.popState();