Skip to content

Commit

Permalink
Fix bugs detected from sonarcloud.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykuku committed Dec 28, 2023
1 parent 73d9a95 commit 52522ba
Show file tree
Hide file tree
Showing 10 changed files with 648 additions and 62 deletions.
1 change: 1 addition & 0 deletions main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"vue-breakpoint-mixin": "^1.5.0",
"vue-codemirror": "^4.0.6",
"vue-custom-scrollbar": "^1.4.4",
"vue-dompurify-html": "2.6.0",
"vue-ellipse-progress": "^1.3.1",
"vue-fullscreen": "^2.6.2",
"vue-i18n": "8.28.2",
Expand Down
2 changes: 1 addition & 1 deletion main/src/components/Apps/AppPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
</div>
<b-progress :value="totalPercentage" format="percent" show-value type="is-primary"></b-progress>
<h3 :class="currentInstallAppTextClass" class="title is-6 has-text-centered" style="height: 20px"
v-html="currentInstallAppText"></h3>
v-dompurify-html="currentInstallAppText"></h3>
</div>
</section>
<!-- App Install Process End -->
Expand Down
12 changes: 2 additions & 10 deletions main/src/components/BrandBar.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<!--
* @LastEditors: Jerryk [email protected]
* @LastEditTime: 2023-02-27 23:35:25
* @FilePath: \CasaOS-UI-0.4.2\src\components\BrandBar.vue
* @Description:
*
* Copyright (c) 2022 by IceWhale, All Rights Reserved.
-->
<template>
<div class="brand-bar is-flex is-align-items-flex-end has-text-white">
<figure class="image _is-136x26 mb-3">
Expand All @@ -16,7 +8,7 @@
<span v-else class="window ml-4">
<ul :style="{ '--time': 5 * line + 's', '--perc': perc, '--line': line }" class="scroll">
<li v-for="(item, key) in rss" :key="key" class="has-text-left" @click="$messageBus('connect_news')">
<a :href="item.link" class="intro-text" target="_blank">{{ item.title }}</a>
<a :href="xss(item.link)" class="intro-text" target="_blank">{{ item.title }}</a>
</li>
</ul>
</span>
Expand All @@ -26,7 +18,7 @@

<script>
import Parser from "rss-parser";
import xss from 'xss'
export default {
name: "brand-bar",
components: {},
Expand Down
2 changes: 1 addition & 1 deletion main/src/components/feedback/FeedbackPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
type="textarea"></b-input>
</b-field>
<b-field :label="$t('System infomation')">
<div class="feedback-info-container is-size-14px" v-html="markdownToHtml"></div>
<div class="feedback-info-container is-size-14px" v-dompurify-html="markdownToHtml"></div>
</b-field>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion main/src/components/logsAndTerminal/LogsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<b-icon :icon="buttonIcon"></b-icon>
</a>
<div id="logs" :class="[fullscreen ? 'fullheight' : 'sheight']" class="logs scrollbars">
<div contenteditable v-html="data" class="content"></div>
<div contenteditable v-dompurify-html="data" class="content"></div>
</div>
</fullscreen>
</template>
Expand Down
2 changes: 1 addition & 1 deletion main/src/components/settings/UpdateCompleteModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<!-- Modal-Card Body Start -->
<section class="modal-card-body ">
<div class="node-card mt-5 mb-5">
<div class="update-info-container is-size-14px " v-html="markdownToHtml"></div>
<div class="update-info-container is-size-14px " v-dompurify-html="markdownToHtml"></div>
<div class="mt-2rem">
<h3 class="title is-5 mb-2">{{ $t('Let more friends know') }}</h3>
<div class=" is-size-14px">{{ $t('Please share to friends who are concerned about family and data privacy to join and use CasaOS.') }}
Expand Down
4 changes: 2 additions & 2 deletions main/src/components/settings/UpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<!-- Modal-Card Body Start -->
<section class="modal-card-body ">
<div class="node-card fixed-height">
<div v-if="!isUpdating" class="update-info-container is-size-14px" v-html="markdownToHtml"></div>
<div v-else class="update-info-container is-size-14px" v-html="updateMarkdownHtml"></div>
<div v-if="!isUpdating" class="update-info-container is-size-14px" v-dompurify-html="markdownToHtml"></div>
<div v-else class="update-info-container is-size-14px" v-dompurify-html="updateMarkdownHtml"></div>
</div>
</section>
<!-- Modal-Card Body End -->
Expand Down
37 changes: 21 additions & 16 deletions main/src/main.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import 'intersection-observer'
import Vue from 'vue'
import App from '@/App.vue'
import router from '@/router'
import store from '@/store'
import i18n from '@/plugins/i18n'
import api from '@/service/api.js'
import openAPI from '@/service/index.js'
import Buefy from 'buefy'
import VueFullscreen from 'vue-fullscreen'
import Vue2TouchEvents from 'vue2-touch-events'
import Vue from 'vue'
import App from '@/App.vue'
import router from '@/router'
import store from '@/store'
import i18n from '@/plugins/i18n'
import api from '@/service/api.js'
import openAPI from '@/service/index.js'
import Buefy from 'buefy'
import VueFullscreen from 'vue-fullscreen'
import Vue2TouchEvents from 'vue2-touch-events'
import VueSocialSharing from 'vue-social-sharing'
import VueSocketIOExt from 'vue-socket.io-extended';
import messageBus from '@/events/index.js'
import xss from 'xss';
import VueSocketIOExt from 'vue-socket.io-extended';
import messageBus from '@/events/index.js'
import VueDOMPurifyHTML from 'vue-dompurify-html'


// Import Styles
import '@/assets/scss/app.scss'
import VAnimateCss from 'v-animate-css';
import VAnimateCss from 'v-animate-css';

const io = require("socket.io-client");

Expand All @@ -39,10 +39,15 @@ const socket = io(wsURL, {

Vue.use(Buefy)
Vue.use(VueFullscreen)
Vue.use(VAnimateCss, {animateCSSPath: '/css/animate.min.css'});
Vue.use(VAnimateCss, { animateCSSPath: '/css/animate.min.css' });
Vue.use(Vue2TouchEvents)
Vue.use(VueSocketIOExt, socket);
Vue.use(VueSocialSharing);
Vue.use(VueDOMPurifyHTML, {
default: {
ALLOWED_ATTR: ['target', 'href']
}
});

Vue.config.productionTip = false
Vue.prototype.$api = api;
Expand All @@ -51,7 +56,7 @@ Vue.prototype.$baseIp = baseIp;
Vue.prototype.$baseURL = baseURL;
Vue.prototype.$protocol = protocol;
Vue.prototype.$wsProtocol = wsProtocol;
Vue.prototype.xss = xss;


// Create an EventBus
Vue.prototype.$EventBus = new Vue();
Expand Down
16 changes: 0 additions & 16 deletions main/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@ module.exports = {
.type("javascript/auto")
.include.add(/node_modules/)
.end();

config.module
.rule("vue")
.use("vue-loader")
.loader("vue-loader")
.tap(options => {
options.compilerOptions.directives = {
html(node, directiveMeta) {
(node.props || (node.props = [])).push({
name: "innerHTML",
value: `xss(_s(${directiveMeta.value}))`
});
}
};
return options;
});
const oneOfsMap = config.module.rule("scss").oneOfs.store;
oneOfsMap.forEach(item => {
item
Expand Down
Loading

0 comments on commit 52522ba

Please sign in to comment.