-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
html/template: ``literal cut off #29406
Comments
/cc @mvdan |
Smaller repro: https://play.golang.org/p/Me6SXmTA4Kt I see that this happens with backquotes, but not single or double quotes. It appears like backquotes were added much later in JS, and have been modified in ES2016 and ES2018: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals Adding support for them, as long as they're well understood and the code is simple, seems fair enough to me. I don't know what the policy is in regards to what JS features |
After a bit of search, I realised this was brought up years ago, so I'm closing this issue as a duplicate of #9200. |
@mvdan Wow that is a brilliiant discovery, but I think there is a bit of a difference between these two issues. #9200 mentioned that template directives that took place inside quasi literals are not properly escaped to get rid of injected placeholders with executable code. Thus it requires at least one formatting directive to be reproduced. However, in this issue the reproduction does not need any formatting directive, the reproduction only consisted of a plain template string. Though I am pretty sure that both issues are caused by lack of support on ES6 formatting string. I still have another concern regarding the package: Shouldn't the package just copy what is written on the template as is, if it does not understand what it means? I think instead of silently discarding values without returning any error, which might cause confusion while debugging, maybe this behavior is better: If (part of) the template could not be understood:
|
I've retitled the older issue to be about adding support for template strings. Now this issue is more clearly a duplicate - both issues would be fixed by adding that feature.
No, that would be very complex and subtle. Right now, some of your template bytes are being discarded because they are being parsed as a comment. If you want to work around that before #9200 is fixed, somehow remove the double slash, or instead use single or double quotes. Something we could likely do in the short term is teach |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried to insert a raw js string literal in an html template with a substring
//
(two forward slashes)https://play.golang.org/p/XKpExxgMybM
What did you expect to see?
The original template was output as their are no template directives presentWhat did you see instead?
The second raw string literal is cut off in the middleThe text was updated successfully, but these errors were encountered: