Commit e1fc1aa
Eric Wheeler
fix: eliminate XSS vulnerability in CodeBlock component
Replace dangerouslySetInnerHTML with safer codeToHast approach to render
syntax-highlighted code from Shiki. This eliminates the cross-site scripting
vulnerability while maintaining identical rendering output and performance.
Security considerations:
- Eliminates potential for HTML injection attacks
- Maintains all syntax highlighting capabilities
- Preserves exact visual output
Performance considerations:
- Direct React element creation is more efficient than HTML parsing
- No browser HTML parsing overhead
- Memoization pattern preserved for optimal rendering
This issue was discovered as part of security review #3785.
Fixes: #5156
Signed-off-by: Eric Wheeler <[email protected]>1 parent 992997c commit e1fc1aa
File tree
3 files changed
+20
-6
lines changed- webview-ui
- src/components/common
3 files changed
+20
-6
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
226 | 228 | | |
227 | 229 | | |
228 | 230 | | |
229 | | - | |
| 231 | + | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
| |||
266 | 268 | | |
267 | 269 | | |
268 | 270 | | |
269 | | - | |
| 271 | + | |
270 | 272 | | |
271 | 273 | | |
272 | 274 | | |
| |||
290 | 292 | | |
291 | 293 | | |
292 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
293 | 303 | | |
294 | | - | |
| 304 | + | |
295 | 305 | | |
296 | 306 | | |
297 | 307 | | |
| |||
783 | 793 | | |
784 | 794 | | |
785 | 795 | | |
786 | | - | |
| 796 | + | |
787 | 797 | | |
788 | 798 | | |
789 | 799 | | |
| |||
801 | 811 | | |
802 | 812 | | |
803 | 813 | | |
804 | | - | |
| 814 | + | |
805 | 815 | | |
806 | 816 | | |
807 | 817 | | |
| |||
812 | 822 | | |
813 | 823 | | |
814 | 824 | | |
815 | | - | |
| 825 | + | |
816 | 826 | | |
817 | 827 | | |
818 | 828 | | |
| |||
0 commit comments