Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Merge pull request #39 from ferhensil/master
Browse files Browse the repository at this point in the history
Fix: escape variables after {% endautoescape %}
  • Loading branch information
paularmstrong committed Jan 24, 2012
2 parents 90e1e9d + a508ec1 commit be8f971
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parser.js
Expand Up @@ -214,7 +214,7 @@ exports.parse = function (data, tags, autoescape) {
if (index > 0 && (/^end/).test(tagname)) {
lastToken = _.last(stack[stack.length - 2]);
if ('end' + lastToken.name === tagname) {
if (_.last(stack).name === 'autoescape') {
if (lastToken.name === 'autoescape') {
escape = last_escape;
}
stack.pop();
Expand Down
6 changes: 6 additions & 0 deletions tests/tags.test.js
Expand Up @@ -37,6 +37,12 @@ exports.autoescape = testCase({
test.done();
},

off_after_close_tag: function (test) {
var tpl = swig.compile('{% autoescape off %}{% endautoescape %}{{ foo }}');
test.strictEqual(tpl({ foo: '<\'single\' & "double" quotes>' }), '&lt;&#39;single&#39; &amp; &quot;double&quot; quotes&gt;');
test.done();
},

js: function (test) {
var tpl = swig.compile('{% autoescape on "js" %}{{ foo }}{% endautoescape %}');
test.strictEqual(tpl({ foo: '"double quotes" and \'single quotes\'' }), '\\u0022double quotes\\u0022 and \\u0027single quotes\\u0027');
Expand Down

0 comments on commit be8f971

Please sign in to comment.