On SSR, script tag escaped
See original GitHub issueVersion
2.5.22
Reproduction link
https://codesandbox.io/s/kx35l39lkv
Steps to reproduce
Open tab Console
What is expected?
<script data-server-rendered="true">
var a = 'a';
var x = "x";
if (a && x) {}
if (a > x) {}
if (a < x) {}
</script>
What is actually happening?
<script data-server-rendered="true">
var a = 'a';
var x = "x";
if (a && x) {}
if (a > x) {}
if (a < x) {}
</script>
There are no restrictions on rendering script
tags on the server
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Escape </ in script tag contents - html - Stack Overflow
I came here looking for a way to universally escape </script> inside the JavaScript code. After bit of research I figured that if...
Read more >Improving Redux state transfer performance with JSON.parse ...
Conclusion: JSON String inside a real <script> tag wins by a shocking margin. An 18% TTI improvement on an already pretty fast app...
Read more >escapeInject - vite-plugin-ssr
The escapeInject string template tag sanitizes HTML (to prevent so-called XSS injections security breaches). It's usually used in the render() hook defined ...
Read more >Security - Vue.js
Vue templates are compiled into JavaScript, and expressions inside templates will be executed as part of ... then it would be escaped to...
Read more >API Reference | Vue Meta
ssrAppId. type string; default ssr. The app id for a server side rendered app. ... If you wish to use a JSON variable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still we can not prohibit the use of
Vue
as a pure server renderer, when no client hydration needed.Possible ugly hack thanks to
v-pre
directive…For simple server side html generation with just a few lines of javascript needed on frontend we really do not want to implement client hydration and add client.js with several hundreds of kB.
In future it will be nice to have some per-element option e.g.
v-noescape
. Everyone who use it know what and why he is doing - so sane developer will not use it for user input (the same as existsv-html
- it is developer responsibility for input). I need <script> tag in template, I do not want it outside template and set using v-html as mentioned here https://github.com/vuejs/vue/issues/8996#issuecomment-433479939.