File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,12 @@ export function urlDecode(_encoded: string): string {
1717 const encoded = undoUrlSafeBase64 ( _encoded )
1818 return globalThis . atob ( encoded )
1919}
20+
21+ export function escapeHtml ( unsafe : string ) {
22+ return unsafe
23+ . replace ( / & / g, '&' )
24+ . replace ( / < / g, '<' )
25+ . replace ( / > / g, '>' )
26+ . replace ( / " / g, '"' )
27+ . replace ( / ' / g, ''' )
28+ }
Original file line number Diff line number Diff line change 8787
8888<script >
8989import pako from ' pako'
90- import { undoUrlSafeBase64 } from ' ../helpers/utils'
90+ import { undoUrlSafeBase64 , escapeHtml } from ' ../helpers/utils'
9191export default {
9292 layout: ' main' ,
9393 data () {
@@ -107,7 +107,9 @@ export default {
107107 if (hunkState === - 1 || hunkState === 0 ) {
108108 const className =
109109 hunkState === - 1 ? ' isModified bg-red-300 dark:bg-yellow-900' : ' '
110- return ` <span class="break-all inline p-0 m-0 ${ className} ">${ item[1 ]} </span>`
110+ return ` <span class="break-all inline p-0 m-0 ${ className} ">${ escapeHtml (
111+ item[1 ]
112+ )} </span>`
111113 }
112114 return false
113115 })
@@ -120,7 +122,9 @@ export default {
120122 if (hunkState === 1 || hunkState === 0 ) {
121123 const className =
122124 hunkState === 1 ? ' isModified bg-green-300 dark:bg-green-900' : ' '
123- return ` <span class="break-all inline p-0 m-0 ${ className} ">${ item[1 ]} </span>`
125+ return ` <span class="break-all inline p-0 m-0 ${ className} ">${ escapeHtml (
126+ item[1 ]
127+ )} </span>`
124128 }
125129 return false
126130 })
You can’t perform that action at this time.
0 commit comments