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

Escape template names #541

Merged

Conversation

aredridel
Copy link
Contributor

Since the compiler was not interpreting template names when emitting
javascript code with those as literals, and instead merely concatenating
string delimiters onto the end, template names ending in a backslash
or containing a newline or double quotes would cause a parser failure
when loading the compiled template.

This additionally escapes the null character, as some browsers will omit
it during parsing, making the template name not make a round-trip from
what was specified to what is cached.

@sethkinast
Copy link
Contributor

This is similar to #422

I think I would prefer to use our builtin function dust.escapeJs if anything?

Is there a test case you can add to show the failure? Thanks!

@aredridel
Copy link
Contributor Author

Yeah, I can do that!

I was not aware of escapeJs, I'll check that out.

@aredridel aredridel force-pushed the escape-template-names-properly branch from 46b0207 to 4f292a0 Compare February 13, 2015 18:35
@aredridel
Copy link
Contributor Author

Updated, using escapeJs and with a test.

@sethkinast
Copy link
Contributor

Nice, thanks for the test!

👍 from me; please do a rebase and squash if you would before I pull.

Since the compiler was not interpreting template names when emitting
javascript code with those as literals, and instead merely concatenating
string delimiters onto the end, template names ending in a backslash
or containing a newline or double quotes would cause a parser failure
when loading the compiled template.

This additionally escapes the null character, as some browsers will omit
it during parsing, making the template name not make a round-trip from
what was specified to what is cached.
@aredridel aredridel force-pushed the escape-template-names-properly branch from 4f292a0 to f7da460 Compare February 13, 2015 18:48
@aredridel
Copy link
Contributor Author

One commit now rather than two.

@prashn64
Copy link
Contributor

lgtm

sethkinast added a commit that referenced this pull request Feb 13, 2015
Escape template names in case they contain non-JS-safe characters
@sethkinast sethkinast merged commit a44d14d into linkedin:master Feb 13, 2015
@sethkinast
Copy link
Contributor

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants