-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: undefined escape at #836 #843
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,10 +119,12 @@ var filters = { | |
if(str instanceof r.SafeString) { | ||
return str; | ||
} | ||
str = (str === null || str === undefined) ? '' : str; | ||
return r.markSafe(lib.escape(str.toString())); | ||
}, | ||
|
||
safe: function(str) { | ||
str = (str === null || str === undefined) ? '' : str; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return r.markSafe(str); | ||
}, | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1309,10 +1309,22 @@ | |
expect(res).to.be('&><\'"'); | ||
}); | ||
|
||
render('{{ foo }}', { foo: null }, { autoescape: true }, function (err, res) { | ||
expect(res).to.be(''); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
render('{{ foo | safe }}', { foo: null }, { autoescape: true }, function (err, res) { | ||
expect(res).to.be(''); | ||
}); | ||
|
||
render('{{ foo }}', { foo: ['<p>foo</p>']}, { autoescape: true }, function(err, res) { | ||
expect(res).to.be('<p>foo</p>'); | ||
}); | ||
|
||
render('{{ foo | safe }}', { foo: '<p>foo</p>' }, { autoescape: true }, function (err, res) { | ||
expect(res).to.be('<p>foo</p>'); | ||
}); | ||
|
||
render('{{ foo }}', { foo: {toString: function() {return '<p>foo</p>'}}}, { autoescape: true }, function(err, res) { | ||
expect(res).to.be('<p>foo</p>'); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please fix normalize function and remove false from there and use normalize here.
I don't see any idea behind it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe another PR. This one is focus at quick bug fix.
I'm afraid it(change
normalize
) will cause BREAK CHANGE.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'll merge it to 2.x, please prepare pull request for master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you rebase this branch on 2.x?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, hold on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vecmezoni plz review again. The ci is fail, but local test is ok, could you trigger it again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't trigger CI, you can change commit hash and push it with force. It would trigger Appveyour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vecmezoni done, travis is pass.