Skip to content

Commit 8fd757b

Browse files
authored
Merge pull request #1378 from nscuro/welcome-message-dompurify
2 parents ab676a4 + d27c958 commit 8fd757b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/views/administration/configuration/WelcomeMessage.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<div slot="header">
4747
<h4>{{ $t('admin.preview') }}</h4>
4848
</div>
49-
<p><span v-html="welcomeMessage" /></p>
49+
<p><span v-html="sanitizedWelcomeMessage" /></p>
5050
</b-card>
5151
</b-col>
5252
</b-row>
@@ -58,6 +58,7 @@ import axios from 'axios';
5858
import { Switch as cSwitch } from '@coreui/vue';
5959
import configPropertyMixin from '../mixins/configPropertyMixin';
6060
import common from '../../../shared/common';
61+
import DOMPurify from 'dompurify';
6162
6263
export default {
6364
mixins: [configPropertyMixin],
@@ -83,7 +84,11 @@ export default {
8384
this.isWelcomeMessage = common.toBoolean(response.data.propertyValue);
8485
});
8586
},
86-
computed: {},
87+
computed: {
88+
sanitizedWelcomeMessage() {
89+
return DOMPurify.sanitize(this.welcomeMessage);
90+
},
91+
},
8792
methods: {
8893
updateCode() {
8994
const editor = this.$refs.editor;

src/views/pages/Login.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import EventBus from '../../shared/eventbus';
111111
import { getRedirectUrl, getContextPath } from '../../shared/utils';
112112
const qs = require('querystring');
113113
import common from '../../shared/common';
114+
import DOMPurify from 'dompurify';
114115
115116
export default {
116117
name: 'Login',
@@ -156,8 +157,8 @@ export default {
156157
if (this.isWelcomeMessage) {
157158
let message_url = `${this.$api.BASE_URL}/${this.$api.URL_CONFIG_PROPERTY}/public/general/welcome.message.html`;
158159
axios.get(message_url).then((response) => {
159-
this.welcomeMessage = decodeURIComponent(
160-
response.data.propertyValue,
160+
this.welcomeMessage = DOMPurify.sanitize(
161+
decodeURIComponent(response.data.propertyValue),
161162
);
162163
});
163164
}

0 commit comments

Comments
 (0)