Skip to content
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

Tempo has no HTML entity escaping #51

Closed
AaronOpfer opened this issue Aug 28, 2012 · 8 comments
Closed

Tempo has no HTML entity escaping #51

AaronOpfer opened this issue Aug 28, 2012 · 8 comments
Assignees
Milestone

Comments

@AaronOpfer
Copy link

Here's a jsfiddle demonstrating the issue:

http://jsfiddle.net/EtkRL/

Should we escape HTML entities by default starting in 2.0? This would be a "secure by default" approach. Then provide an unescape filter that allows inserting HTML entities in the page.

Alternatively, provide an escape filter and leave stuff unescaped by default.

@mrolafsson
Copy link
Contributor

Yes I agree with this approach.

@ghost ghost assigned mrolafsson Jan 3, 2013
@mrolafsson
Copy link
Contributor

Fixed in 2.0 with escape, encodeURI/decodeURI functions.

@AaronOpfer
Copy link
Author

It looks like to me this doesn't escape data by default, but instead requires the inserted text to be escaped explicitly. This is in my opinion the wrong move, as I think many developers inserting data into their templates wouldn't expect to shoot themselves in the foot by doing so.

@mrolafsson
Copy link
Contributor

Yeah I wasn't sure on that one - too me it's a bit heavy handed to escape by default? I'm open to default - are there not cases where you would want it in clear?

@mrolafsson
Copy link
Contributor

I'm just thinking, what if you've got URLs in the data? You can not reliable "unescape" them I think?

@AaronOpfer
Copy link
Author

Exactly, you'd need to introduce some sort of new syntax. Or, alternatively, you could make the unescape function do something like this:

unescape: function (input) {
    input.tempoDoNotEscape = true;
}

and then later on, when you're getting ready to output the variables, escape all strings that don't have that property on them.

@mrolafsson
Copy link
Contributor

I think I've cracked it Aaron. All values are escaped by default. To disable automatic escaping pass in the 'escape': false parameter:

Tempo.prepare('marx-brothers', {'escape': false}).render(data);

If you disable escaping you can control this at individual value level using the escape and encodeURI filters.

@mrolafsson mrolafsson reopened this Feb 13, 2013
@mrolafsson
Copy link
Contributor

Fixed in 2.0, see http://tempojs.com/2.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants