@@ -72,18 +72,21 @@ export class LookupView {
72
72
)
73
73
)
74
74
. map ( ( item ) => {
75
+ const title = escapeHTML ( item . title ) ;
76
+ const type = escapeHTML ( item . type ) ;
77
+ const content = escapeHTML ( item . content ) ;
75
78
if ( item . range ) {
76
79
const range = JSON . parse ( item . range ) ;
77
80
const sourceRange = `${ range . startRow } :${ range . startColumn } - ${ range . endRow } :${ range . endColumn } ` ;
78
81
return `<dt class="text-truncate" style="max-width: calc(40vw - 20px);">
79
- <span class="badge annotation" style="width: auto; text-align: start;">Text</span><span class="font-monospace">${ item . title } </span>
82
+ <span class="badge annotation" style="width: auto; text-align: start;">Text</span><span class="font-monospace">${ title } </span>
80
83
</dt>
81
- <dd><div><span class="badge annotation">Range</span>${ sourceRange } </div><div><span class="badge annotation">${ item . type } </span>${ item . content } </div></dd>` ;
84
+ <dd><div><span class="badge annotation">Range</span>${ sourceRange } </div><div><span class="badge annotation">${ type } </span>${ content } </div></dd>` ;
82
85
} else {
83
86
return `<dt class="text-truncate" style="max-width: calc(40vw - 20px);">
84
- <span class="badge annotation" style="width: auto; text-align: start;">Text</span><span class="font-monospace">${ item . title } </span>
87
+ <span class="badge annotation" style="width: auto; text-align: start;">Text</span><span class="font-monospace">${ title } </span>
85
88
</dt>
86
- <dd><div><span class="badge annotation">${ item . type } </span>${ item . content } </div></dd>` ;
89
+ <dd><div><span class="badge annotation">${ type } </span>${ content } </div></dd>` ;
87
90
}
88
91
} )
89
92
. join ( "" ) ;
@@ -134,3 +137,9 @@ function createDOMRectElement(domRect) {
134
137
rectElement . style . backgroundColor = "rgba(81, 101, 255, 0.25)" ;
135
138
document . body . appendChild ( rectElement ) ;
136
139
}
140
+
141
+ function escapeHTML ( text ) {
142
+ const div = document . createElement ( "div" ) ;
143
+ div . appendChild ( document . createTextNode ( text ) ) ;
144
+ return div . innerHTML ;
145
+ }
0 commit comments