File tree 3 files changed +34
-8
lines changed
3 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import React from 'react';
2
2
3
3
import { Paper , Divider , TextField , InputAdornment } from '@mui/material' ;
4
4
5
+ import dompurify from 'dompurify' ;
6
+
5
7
import Convert from 'ansi-to-html' ;
6
8
7
9
const convert = new Convert ( ) ;
@@ -50,14 +52,19 @@ export default function Terminal(props: {
50
52
< br />
51
53
52
54
< span className = "terminal-command-output" >
53
- { command . output . map ( ( output : string ) : any => (
54
- < div >
55
- < td
56
- dangerouslySetInnerHTML = { { __html : convert . toHtml ( output ) } }
57
- style = { { paddingLeft : '16px' } }
58
- />
59
- </ div >
60
- ) ) }
55
+ { command . output . map ( ( output : string ) : any => {
56
+ const html = convert . toHtml ( output ) ;
57
+ const sanitizer = dompurify . sanitize ;
58
+
59
+ return (
60
+ < div >
61
+ < td
62
+ dangerouslySetInnerHTML = { { __html : sanitizer ( html ) } }
63
+ style = { { paddingLeft : '16px' } }
64
+ />
65
+ </ div >
66
+ ) ;
67
+ } ) }
61
68
</ span >
62
69
</ div >
63
70
) ) }
Original file line number Diff line number Diff line change 30
30
"body-parser" : " ^1.20.0" ,
31
31
"chalk" : " 4.1.2" ,
32
32
"cors" : " ^2.8.5" ,
33
+ "dompurify" : " ^2.4.0" ,
33
34
"express" : " ^4.18.1" ,
34
35
"jsonwebtoken" : " ^8.5.1" ,
35
36
"monaco-editor" : " ^0.34.0" ,
42
43
},
43
44
"devDependencies" : {
44
45
"@babel/core" : " ^7.19.3" ,
46
+ "@types/dompurify" : " ^2.3.4" ,
45
47
"@types/express" : " ^4.17.14" ,
46
48
"@types/jest" : " ^29.1.1" ,
47
49
"@types/jsonwebtoken" : " ^8.5.9" ,
Original file line number Diff line number Diff line change 1054
1054
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080"
1055
1055
integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==
1056
1056
1057
+ " @types/dompurify@^2.3.4 " :
1058
+ version "2.3.4"
1059
+ resolved "https://registry.yarnpkg.com/@types/dompurify/-/dompurify-2.3.4.tgz#94e997e30338ea24d4c8d08beca91ce4dd17a1b4"
1060
+ integrity sha512-EXzDatIb5EspL2eb/xPGmaC8pePcTHrkDCONjeisusLFrVfl38Pjea/R0YJGu3k9ZQadSvMqW0WXPI2hEo2Ajg==
1061
+ dependencies :
1062
+ " @types/trusted-types" " *"
1063
+
1057
1064
" @types/eslint-scope@^3.7.3 " :
1058
1065
version "3.7.4"
1059
1066
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16"
1262
1269
dependencies :
1263
1270
" @types/superagent" " *"
1264
1271
1272
+ " @types/trusted-types@* " :
1273
+ version "2.0.2"
1274
+ resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.2.tgz#fc25ad9943bcac11cceb8168db4f275e0e72e756"
1275
+ integrity sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==
1276
+
1265
1277
" @types/uuid@^8.3.4 " :
1266
1278
version "8.3.4"
1267
1279
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc"
@@ -2393,6 +2405,11 @@ dom-helpers@^5.0.1:
2393
2405
" @babel/runtime" " ^7.8.7"
2394
2406
csstype "^3.0.2"
2395
2407
2408
+ dompurify@^2.4.0 :
2409
+ version "2.4.0"
2410
+ resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.4.0.tgz#c9c88390f024c2823332615c9e20a453cf3825dd"
2411
+ integrity sha512-Be9tbQMZds4a3C6xTmz68NlMfeONA//4dOavl/1rNw50E+/QO0KVpbcU0PcaW0nsQxurXls9ZocqFxk8R2mWEA==
2412
+
2396
2413
dotenv-defaults@^2.0.2 :
2397
2414
version "2.0.2"
2398
2415
resolved "https://registry.yarnpkg.com/dotenv-defaults/-/dotenv-defaults-2.0.2.tgz#6b3ec2e4319aafb70940abda72d3856770ee77ac"
You can’t perform that action at this time.
0 commit comments