Clean up code, sanitize some inputs
This commit is contained in:
parent
309468e878
commit
e1d3897e5e
|
|
@ -1,4 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<div
|
<div
|
||||||
class="solution"
|
class="solution"
|
||||||
data-cy="solution"
|
data-cy="solution"
|
||||||
|
|
@ -17,13 +18,15 @@
|
||||||
data-cy="solution-text"
|
data-cy="solution-text"
|
||||||
|
|
||||||
v-if="visible"
|
v-if="visible"
|
||||||
v-html="value.text"
|
v-html="sanitizedText"
|
||||||
/>
|
/>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {sanitize} from '@/helpers/text';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['value'],
|
props: ['value'],
|
||||||
|
|
||||||
|
|
@ -33,6 +36,12 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
sanitizedText() {
|
||||||
|
return sanitize(this.value.text);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
toggle() {
|
toggle() {
|
||||||
this.visible = !this.visible;
|
this.visible = !this.visible;
|
||||||
|
|
@ -42,8 +51,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "~styles/helpers";
|
||||||
@import "@/styles/_functions.scss";
|
|
||||||
|
|
||||||
.solution {
|
.solution {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<h5
|
<h5
|
||||||
class="subtitle"
|
class="subtitle"
|
||||||
v-html="value.text"
|
v-html="sanitizedText"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
//todo: esacpe value.text
|
import {sanitize} from '@/helpers/text';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['value']
|
props: ['value'],
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
sanitizedText() {
|
||||||
|
return sanitize(this.value.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "~styles/helpers";
|
||||||
@import "@/styles/_mixins.scss";
|
|
||||||
|
|
||||||
.subtitle {
|
.subtitle {
|
||||||
padding-top: 1px;
|
padding-top: 1px;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,22 @@
|
||||||
<template>
|
<template>
|
||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<div
|
<div
|
||||||
class="text-block"
|
class="text-block"
|
||||||
v-html="value.text"
|
v-html="sanitizedText"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// todo: escape text maybe
|
import {sanitize} from '@/helpers/text';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['value']
|
props: ['value'],
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
sanitizedText() {
|
||||||
|
return sanitize(this.value.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<div
|
<div
|
||||||
:data-scrollto="value.id"
|
:data-scrollto="value.id"
|
||||||
class="assignment"
|
class="assignment"
|
||||||
|
|
@ -62,6 +63,7 @@
|
||||||
import SPELL_CHECK_MUTATION from '@/graphql/gql/mutations/spellCheck.gql';
|
import SPELL_CHECK_MUTATION from '@/graphql/gql/mutations/spellCheck.gql';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
import cloneDeep from 'lodash/cloneDeep';
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
|
import {sanitize} from '@/helpers/text';
|
||||||
|
|
||||||
const SubmissionForm = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/assignment/SubmissionForm');
|
const SubmissionForm = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/assignment/SubmissionForm');
|
||||||
const Solution = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/Solution');
|
const Solution = () => import(/* webpackChunkName: "content-components" */'@/components/content-blocks/Solution');
|
||||||
|
|
@ -112,9 +114,9 @@
|
||||||
return this.assignment.id ? this.assignment.id.replace(/=/g, '') : '';
|
return this.assignment.id ? this.assignment.id.replace(/=/g, '') : '';
|
||||||
},
|
},
|
||||||
feedbackText() {
|
feedbackText() {
|
||||||
// todo: should we maybe clean up this feedback text?
|
|
||||||
let feedback = this.assignment.submission.submissionFeedback;
|
let feedback = this.assignment.submission.submissionFeedback;
|
||||||
return `<span class="inline-title">Feedback von ${feedback.teacher.firstName} ${feedback.teacher.lastName}:</span> ${feedback.text}`;
|
let sanitizedFeedbackText = sanitize(feedback.text);
|
||||||
|
return `<span class="inline-title">Feedback von ${feedback.teacher.firstName} ${feedback.teacher.lastName}:</span> ${sanitizedFeedbackText}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import ADD_NOTE_MUTATION from '@/graphql/gql/mutations/addNote.gql';
|
import ADD_NOTE_MUTATION from '@/graphql/gql/mutations/addNote.gql';
|
||||||
import CONTENT_BLOCK_QUERY from '@/graphql/gql/queries/contentBlockQuery.gql';
|
import CONTENT_BLOCK_QUERY from '@/graphql/gql/queries/contentBlockQuery.gql';
|
||||||
import CHAPTER_QUERY from '@/graphql/gql/queries/chapterQuery.gql';
|
import CHAPTER_QUERY from '@/graphql/gql/queries/chapterQuery.gql';
|
||||||
import MODULE_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
|
||||||
import INSTRUMENT_FRAGMENT from '@/graphql/gql/fragments/instrumentParts.gql';
|
import INSTRUMENT_FRAGMENT from '@/graphql/gql/fragments/instrumentParts.gql';
|
||||||
import gql from 'graphql-tag';
|
|
||||||
import MODULE_FRAGMENT from '@/graphql/gql/fragments/moduleParts.gql';
|
import MODULE_FRAGMENT from '@/graphql/gql/fragments/moduleParts.gql';
|
||||||
import {replaceAtIndex} from '@/graphql/immutable-operations';
|
import {replaceAtIndex} from '@/graphql/immutable-operations';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const sanitize = html => {
|
export const sanitize = html => {
|
||||||
let doc = new DOMParser().parseFromString(html, 'text/html');
|
let doc = new DOMParser().parseFromString(html, 'text/html');
|
||||||
return doc.body.textContent || '';
|
return doc.body.textContent || '';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@
|
||||||
import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.gql';
|
import NEW_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/addContentBlock.gql';
|
||||||
import {setUserBlockType} from '@/helpers/content-block';
|
import {setUserBlockType} from '@/helpers/content-block';
|
||||||
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
import MODULE_DETAILS_QUERY from '@/graphql/gql/queries/modules/moduleDetailsQuery.gql';
|
||||||
import {insertAtIndex, removeAtIndex, replaceAtIndex} from '@/graphql/immutable-operations';
|
import {removeAtIndex, replaceAtIndex} from '@/graphql/immutable-operations';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue