Skip to content

Disable interpolation (mustache-style directives). Vue unusable for apps with user content. #4223

@sebastiaanluca

Description

@sebastiaanluca

Vue.js version

2.0.5

Reproduction Link

http://codepen.io/anon/pen/pNbQeY

Steps to reproduce

  1. An app built around user content
  2. Vue instance bound to app container
  3. 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.
  • 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.

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 or v-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

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions