From 8d5530ee2c3ea9f0aee3fde310b9f36887d00b8b Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Sun, 20 Oct 2019 22:53:56 +0200 Subject: [PATCH 1/3] fix: non-eager matching raw-block-contents In 4.4.4 the block-contents was matched with an eager match, which means that with multiple raw-blocks of the same kind, the block was spanned over the first ending-tag until the last one. This commit replaces this by a non-eager match. closes #1579 --- spec/helpers.js | 10 +++++++++- spec/tokenizer.js | 5 +++++ src/handlebars.l | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/spec/helpers.js b/spec/helpers.js index 0e756aba3..f95817c6a 100644 --- a/spec/helpers.js +++ b/spec/helpers.js @@ -47,10 +47,18 @@ describe('helpers', function() { runWithIdentityHelper('{{{{identity}}}}{{{{/identity}}}}', ''); }); - it('helper for nested raw block works if nested raw blocks are broken', function() { + xit('helper for nested raw block works if nested raw blocks are broken', function() { + // This test was introduced in 4.4.4, but it was not the actual problem that lead to the patch release + // The test is deactivated, because in 3.x this template cases an exception and it also does not work in 4.4.3 + // If anyone can make this template work without breaking everything else, then go for it, + // but for now, this is just a known bug, that will be documented. runWithIdentityHelper('{{{{identity}}}} {{{{a}}}} {{{{ {{{{/ }}}} }}}} {{{{/identity}}}}', ' {{{{a}}}} {{{{ {{{{/ }}}} }}}} '); }); + it('helper for nested raw block closes after first matching close', function() { + runWithIdentityHelper('{{{{identity}}}}abc{{{{/identity}}}} {{{{identity}}}}abc{{{{/identity}}}}', 'abc abc'); + }); + it('helper for nested raw block throw exception when with missing closing braces', function() { var string = '{{{{a}}}} {{{{/a'; shouldThrow(function() { diff --git a/spec/tokenizer.js b/spec/tokenizer.js index 1a361b754..ec15d597f 100644 --- a/spec/tokenizer.js +++ b/spec/tokenizer.js @@ -441,4 +441,9 @@ describe('Tokenizer', function() { result = tokenize('{{else foo as |bar baz|}}'); shouldMatchTokens(result, ['OPEN_INVERSE_CHAIN', 'ID', 'OPEN_BLOCK_PARAMS', 'ID', 'ID', 'CLOSE_BLOCK_PARAMS', 'CLOSE']); }); + + it('tokenizes raw blocks', function() { + var result = tokenize('{{{{a}}}} abc {{{{/a}}}} aaa {{{{a}}}} abc {{{{/a}}}}'); + shouldMatchTokens(result, ['OPEN_RAW_BLOCK', 'ID', 'CLOSE_RAW_BLOCK', 'CONTENT', 'END_RAW_BLOCK', 'CONTENT', 'OPEN_RAW_BLOCK', 'ID', 'CLOSE_RAW_BLOCK', 'CONTENT', 'END_RAW_BLOCK']); + }); }); diff --git a/src/handlebars.l b/src/handlebars.l index 2b27a9fab..fbf208b48 100644 --- a/src/handlebars.l +++ b/src/handlebars.l @@ -63,7 +63,7 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD} return 'END_RAW_BLOCK'; } } -[^\x00]+/("{{{{") { return 'CONTENT'; } +[^\x00]+?/("{{{{") { return 'CONTENT'; } [\s\S]*?"--"{RIGHT_STRIP}?"}}" { this.popState(); From def79fd5d60bc73ead4c69125dc6f24e4793a056 Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Sun, 20 Oct 2019 23:07:22 +0200 Subject: [PATCH 2/3] Update release notes --- release-notes.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/release-notes.md b/release-notes.md index eb60913a5..4d5bfbf68 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,7 +2,16 @@ ## Development -[Commits](https://github.com/wycats/handlebars.js/compare/v4.4.4...master) +[Commits](https://github.com/wycats/handlebars.js/compare/v4.4.5...master) + +## v4.4.5 - October 20th, 2019 +Bugfixes: + +- Contents of raw-blocks must be matched with non-eager regex-matching - 8d5530e, #1579 + + + +[Commits](https://github.com/wycats/handlebars.js/compare/v4.4.4...v4.4.5) ## v4.4.4 - October 20th, 2019 Bugfixes: From 8e1cce79186ab6caeb8c6ec9c1f8bcfa1a40e83d Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Sun, 20 Oct 2019 23:08:10 +0200 Subject: [PATCH 3/3] v4.4.5 --- components/bower.json | 2 +- components/handlebars.js.nuspec | 2 +- components/package.json | 2 +- lib/handlebars/base.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/bower.json b/components/bower.json index fc7a33709..de0d3edf7 100644 --- a/components/bower.json +++ b/components/bower.json @@ -1,6 +1,6 @@ { "name": "handlebars", - "version": "4.4.4", + "version": "4.4.5", "main": "handlebars.js", "license": "MIT", "dependencies": {} diff --git a/components/handlebars.js.nuspec b/components/handlebars.js.nuspec index 653078c14..5c03a0795 100644 --- a/components/handlebars.js.nuspec +++ b/components/handlebars.js.nuspec @@ -2,7 +2,7 @@ handlebars.js - 4.4.4 + 4.4.5 handlebars.js Authors https://github.com/wycats/handlebars.js/blob/master/LICENSE https://github.com/wycats/handlebars.js/ diff --git a/components/package.json b/components/package.json index e8e6f1cba..db8c6a638 100644 --- a/components/package.json +++ b/components/package.json @@ -1,6 +1,6 @@ { "name": "handlebars", - "version": "4.4.4", + "version": "4.4.5", "license": "MIT", "jspm": { "main": "handlebars", diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js index 2b7709200..eccdb4753 100644 --- a/lib/handlebars/base.js +++ b/lib/handlebars/base.js @@ -4,7 +4,7 @@ import {registerDefaultHelpers} from './helpers'; import {registerDefaultDecorators} from './decorators'; import logger from './logger'; -export const VERSION = '4.4.4'; +export const VERSION = '4.4.5'; export const COMPILER_REVISION = 8; export const LAST_COMPATIBLE_COMPILER_REVISION = 7; diff --git a/package.json b/package.json index de7e3da01..40391a611 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "handlebars", "barename": "handlebars", - "version": "4.4.4", + "version": "4.4.5", "description": "Handlebars provides the power necessary to let you build semantic templates effectively with no frustration", "homepage": "http://www.handlebarsjs.com/", "keywords": [