Skip to content

Escape values passed from Rails to Vue to make sure the template can be compiled

Douwe Maan requested to merge dm-fix-vue-cant-compile-some-discussions into master

Any note that includes ' would trigger this bug.

Before

Screen_Shot_2017-03-21_at_13.26.27

JS error:

Vue warn]: failed to compile template:

<resolve-btn :author-name="'Administrator'" :can-resolve="true" :note-id="1275" :note-truncated="'I&amp;#39;d add:

```
...'" :resolved="false" :resolved-by="''" author-avatar="http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&amp;d=identicon" discussion-id="657bb606799816676d22bd79aa3cdad1a94974ad" inline-template="true" project-path="/gitlab-org/gitlab-test" ref="note_1275" v-show="true">
<button :aria-label="buttonText" :class="{ 'is-active': isResolved }" :ref="'button'" :title="buttonText" @click="resolve" class="line-resolve-btn note-action-button" type="button" v-show="!loading">
<i v-show="loading" class="fa fa-spin fa-spinner"></i>
<svg width="14" height="14" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"><g fill-rule="evenodd"><path d="M0 7a7 7 0 1 1 14 0A7 7 0 0 1 0 7z"></path><path d="M13 7A6 6 0 1 0 1 7a6 6 0 0 0 12 0z" fill="#FFF"></path><path d="M6.278 7.697L5.045 6.464a.296.296 0 0 0-.42-.002l-.613.614a.298.298 0 0 0 .002.42l1.91 1.909a.5.5 0 0 0 .703.005l.265-.265L9.997 6.04a.291.291 0 0 0-.009-.408l-.614-.614a.29.29 0 0 0-.408-.009L6.278 7.697z"></path></g></svg>

</button>
</resolve-btn>

- invalid expression: :note-truncated="'I&#39;d add:

```
...'"

 
(found in root instance)

After

Screen_Shot_2017-03-21_at_13.26.38

Merge request reports