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 ampersand and single quote? #3

Closed
escholtz opened this issue Apr 5, 2016 · 3 comments
Closed

Escape ampersand and single quote? #3

escholtz opened this issue Apr 5, 2016 · 3 comments

Comments

@escholtz
Copy link
Contributor

escholtz commented Apr 5, 2016

Looks like the escaper in the html package escapes single quotes:
https://golang.org/src/html/escape.go?s=3992:4005#L172

It appears that quicktemplate does not. Is that safe?

@valyala
Copy link
Owner

valyala commented Apr 5, 2016

quicktemplate should escape single quotes - see the corresponding code and this test.

Could you provide a short quicktemplate example, which doesn't escape single quote?

@escholtz
Copy link
Contributor Author

escholtz commented Apr 5, 2016

Ooops, you are correct. Thanks for the quick response and sorry for wasting your time.

On 2nd glance, looks like the html package also remaps & to &. Does that need to be added?

Test:

{% func TestEscapeAmpersand() %}
  {%s "&" %}
{% endfunc %}

valyala added a commit that referenced this issue Apr 5, 2016
@valyala
Copy link
Owner

valyala commented Apr 5, 2016

looks like the html package also remaps & to &. Does that need to be added?

Yes! Fixed it!

@valyala valyala changed the title Escape single quote? Escape ampersand and single quote? Apr 5, 2016
@valyala valyala closed this as completed Apr 5, 2016
valyala added a commit to Vertamedia/quicktemplate that referenced this issue Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants