Commit 5994265f authored by Phil Hughes's avatar Phil Hughes

Escape characters in diff view function definitions

parent 0578cc5c
<script> <script>
import { GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
import { mapGetters, mapState, mapActions } from 'vuex'; import { mapGetters, mapState, mapActions } from 'vuex';
import { IdState } from 'vendor/vue-virtual-scroller'; import { IdState } from 'vendor/vue-virtual-scroller';
import DraftNote from '~/batch_comments/components/draft_note.vue'; import DraftNote from '~/batch_comments/components/draft_note.vue';
...@@ -19,6 +20,9 @@ export default { ...@@ -19,6 +20,9 @@ export default {
DiffCommentCell, DiffCommentCell,
DraftNote, DraftNote,
}, },
directives: {
SafeHtml,
},
mixins: [ mixins: [
draftCommentsMixin, draftCommentsMixin,
glFeatureFlagsMixin(), glFeatureFlagsMixin(),
...@@ -173,15 +177,17 @@ export default { ...@@ -173,15 +177,17 @@ export default {
<div class="diff-grid-left diff-grid-3-col left-side"> <div class="diff-grid-left diff-grid-3-col left-side">
<div class="diff-td diff-line-num"></div> <div class="diff-td diff-line-num"></div>
<div v-if="inline" class="diff-td diff-line-num"></div> <div v-if="inline" class="diff-td diff-line-num"></div>
<div class="diff-td line_content left-side gl-white-space-normal!"> <div
{{ line.left.rich_text }} v-safe-html="line.left.rich_text"
</div> class="diff-td line_content left-side gl-white-space-normal!"
></div>
</div> </div>
<div v-if="!inline" class="diff-grid-right diff-grid-3-col right-side"> <div v-if="!inline" class="diff-grid-right diff-grid-3-col right-side">
<div class="diff-td diff-line-num"></div> <div class="diff-td diff-line-num"></div>
<div class="diff-td line_content right-side gl-white-space-normal!"> <div
{{ line.left.rich_text }} v-safe-html="line.left.rich_text"
</div> class="diff-td line_content right-side gl-white-space-normal!"
></div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -51,10 +51,18 @@ describe('DiffView', () => { ...@@ -51,10 +51,18 @@ describe('DiffView', () => {
it('renders a match line', () => { it('renders a match line', () => {
const wrapper = createWrapper({ const wrapper = createWrapper({
diffLines: [{ isMatchLineLeft: true, left: { rich_text: 'matched text', lineDraft: {} } }], diffLines: [
{
isMatchLineLeft: true,
left: {
rich_text: '@@ -4,12 +4,12 @@ import createFlash from &#39;~/flash&#39;;',
lineDraft: {},
},
},
],
}); });
expect(wrapper.find(DiffExpansionCell).exists()).toBe(true); expect(wrapper.find(DiffExpansionCell).exists()).toBe(true);
expect(wrapper.text()).toContain('matched text'); expect(wrapper.text()).toContain("@@ -4,12 +4,12 @@ import createFlash from '~/flash';");
}); });
it.each` it.each`
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment