Skip to content

Commit

Permalink
bugfix: copyright markdown解析问题 TencentBlueKing#1471
Browse files Browse the repository at this point in the history
  • Loading branch information
hLinx committed Nov 11, 2022
1 parent d1978fb commit f806343
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"vue-progressbar": "0.7.5",
"vue-router": "3.5.2",
"vuedraggable": "2.23.2",
"vuex": "3.6.2"
"vuex": "3.6.2",
"xss": "^1.0.14"
},
"devDependencies": {
"@babel/core": "^7.17.10",
Expand Down
16 changes: 14 additions & 2 deletions src/frontend/src/views/home/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
</template>
<script>
import marked from 'marked';
import xss from 'xss';
import QueryGlobalSettingService from '@service/query-global-setting';
import LayoutCard from './components/card';
import User from './components/user';
Expand All @@ -85,6 +86,17 @@
import FavorTask from './components/favor-task';
import HistoryRecord from './components/history-record';
const xssHTML = (html) => {
const attrs = ['class', 'title', 'target', 'style'];
return xss(html, {
onTagAttr: (tag, name, value, isWhiteAttr) => {
if (attrs.includes(name)) {
return `${name}=${value}`;
}
},
});
};
export default {
name: '',
components: {
Expand All @@ -109,8 +121,8 @@
const formatLink = link => link.replace(/(?=( href))/g, ' target="_blank"');
QueryGlobalSettingService.fetchFooterConfig()
.then((data) => {
this.footerLink = formatLink(marked(`${data.footerLink}`));
this.footerCopyRight = marked(data.footerCopyRight);
this.footerLink = xssHTML(formatLink(marked(`${data.footerLink}`)));
this.footerCopyRight = xssHTML(marked(data.footerCopyRight));
});
},
},
Expand Down

0 comments on commit f806343

Please sign in to comment.