1
1
<template >
2
- <div class =" rich-text" v-html =" htmlContent" ></div >
3
- </template >
4
-
5
- <script setup lang="ts">
6
- import type { AdminForthResourceColumnCommon , AdminForthResourceCommon , AdminUser } from ' @/types/Common'
7
-
8
- const props = defineProps <{
9
- column: AdminForthResourceColumnCommon
10
- record: any
11
- meta: any
12
- resource: AdminForthResourceCommon
13
- adminUser: AdminUser
14
- }>()
15
-
16
- const htmlContent = props .record [props .column .name ] || ' '
17
- </script >
18
-
19
- <style scoped>
20
- .rich-text {
21
- /* You can add default styles here if needed */
22
- word-break : break-word ;
23
- }
24
- </style >
25
-
2
+ <div class =" rich-text" v-html =" htmlContent" ></div >
3
+ </template >
4
+
5
+ <script setup lang="ts">
6
+ import type { AdminForthResourceColumnCommon , AdminForthResourceCommon , AdminUser } from ' @/types/Common'
7
+ import { protectAgainstXSS } from ' @/components/ValueRenderer.vue' // путь замени на актуальный
8
+ import sanitizeHtml from ' sanitize-html' ;
9
+
10
+ const props = defineProps <{
11
+ column: AdminForthResourceColumnCommon
12
+ record: any
13
+ meta: any
14
+ resource: AdminForthResourceCommon
15
+ adminUser: AdminUser
16
+ }>()
17
+ function protectAgainstXSS(value : string ) {
18
+ return sanitizeHtml (value , {
19
+ allowedTags: [
20
+ " address" , " article" , " aside" , " footer" , " header" , " h1" , " h2" , " h3" , " h4" ,
21
+ " h5" , " h6" , " hgroup" , " main" , " nav" , " section" , " blockquote" , " dd" , " div" ,
22
+ " dl" , " dt" , " figcaption" , " figure" , " hr" , " li" , " main" , " ol" , " p" , " pre" ,
23
+ " ul" , " a" , " abbr" , " b" , " bdi" , " bdo" , " br" , " cite" , " code" , " data" , " dfn" ,
24
+ " em" , " i" , " kbd" , " mark" , " q" , " rb" , " rp" , " rt" , " rtc" , " ruby" , " s" , " samp" ,
25
+ " small" , " span" , " strong" , " sub" , " sup" , " time" , " u" , " var" , " wbr" , " caption" ,
26
+ " col" , " colgroup" , " table" , " tbody" , " td" , " tfoot" , " th" , " thead" , " tr" , ' img'
27
+ ],
28
+ allowedAttributes: {
29
+ ' li' : [ ' data-list' ],
30
+ ' img' : [ ' src' , ' srcset' , ' alt' , ' title' , ' width' , ' height' , ' loading' ]
31
+ }
32
+ });
33
+ }
34
+ const htmlContent = protectAgainstXSS (props .record [props .column .name ])
35
+
36
+ </script >
37
+
38
+ <style scoped>
39
+ .rich-text {
40
+ /* You can add default styles here if needed */
41
+ word-break : break-word ;
42
+ }
43
+ </style >
0 commit comments