-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Description
Vue.js version
2.0.5
Reproduction Link
http://codepen.io/anon/pen/pNbQeY
Steps to reproduce
- An app built around user content
- Vue instance bound to app container
- User content contains curly braces (
{{
and}}
)
What is Expected?
Curly braces in non-app, user content are ignored. Especially when encoded.
What is actually happening?
User can crash Vue and thus the application by simply using the curly braces syntax anywhere their input is rendered, i.e. {{ myvalue }}
and {{ myvalue }}
.
Solutions that did not work
- Encoding the curly braces;
{{ myvalue }}
- Creating several Vue instances and binding them only to non-user content. Whenever a Vue component needs to render user content, use
v-html
.- This is not a viable solution as it would require a developer to create a Vue instance per Vue component seperately. Each component would then also have to use the
v-html
syntax, which prevents using third-party, non-Vue code they have no access to.
- This is not a viable solution as it would require a developer to create a Vue instance per Vue component seperately. Each component would then also have to use the
- Changing delimiters
- The problem remains and the user can still crash the app.
- Disabling delimiters (interpolation)
- Not supported. Tried
delimiters: ['', '']
which causes Vue to render every single element.
- Not supported. Tried
Propositions
- Bring back
Vue.config({ interpolate: false })
(Option to disable parsing mustache-style directives #147 (comment)) or a non-global option per Vue instance. - A new tag, e.g.
v-ignore-delimiters
orv-disable-interpolation
, to disable{{ myvalue }}
rendering inside that HTML tag, but still allow it to be altered using Vue or act as a Vue component.
Related issues
- Original question: https://forum.vuejs.org/t/html-content-with-vue-syntax-makes-my-instance-crash/2998/3
- Similar request for Vue 1: Option to disable parsing mustache-style directives #147
- Similar request: https://forum-archive.vuejs.org/topic/5354/a-case-for-keeping-interpolate/2
- Other languages: Anyway to disable curly braces interpolation in markdown? hexojs/hexo#1079 and http://stackoverflow.com/questions/25710698/escaping-the-double-curly-braces-in-swig-templates-for-angularjs
- Also related to the Laravel Blade discussion of having syntax to ignore braces and render it without parsing
Perhaps I'm completely missing the point, but at the moment, this prevents me from using Vue in my app. I didn't think this would be a major issue, yet it's proven itself to be quite cumbersome to fix or bypass. Not sure how others handle this situation. Would love to get some feedback on this and be able to continue development using Vue.
Metadata
Metadata
Assignees
Labels
No labels