mirror of
https://github.com/status-im/codimd.git
synced 2025-01-11 23:14:24 +00:00
Escape html for table cell
Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
parent
b29d2c0a31
commit
1adf1221c6
@ -1,4 +1,5 @@
|
|||||||
import Papa from 'papaparse'
|
import Papa from 'papaparse'
|
||||||
|
import escapeHTML from 'lodash/escape'
|
||||||
|
|
||||||
const safeParse = d => {
|
const safeParse = d => {
|
||||||
try {
|
try {
|
||||||
@ -22,12 +23,12 @@ export function renderCSVPreview (csv, options = {}, attr = '') {
|
|||||||
return `<table ${attr}>
|
return `<table ${attr}>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
${fields.map(f => `<th>${f}</th>`).join('')}
|
${fields.map(f => `<th>${escapeHTML(f)}</th>`).join('')}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
${results.data.map(d => `<tr>
|
${results.data.map(d => `<tr>
|
||||||
${fields.map(f => `<td>${d[f]}</td>`).join('')}
|
${fields.map(f => `<td>${escapeHTML(d[f])}</td>`).join('')}
|
||||||
</tr>`).join('')}
|
</tr>`).join('')}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>`
|
</table>`
|
||||||
@ -35,7 +36,7 @@ export function renderCSVPreview (csv, options = {}, attr = '') {
|
|||||||
return `<table ${attr}>
|
return `<table ${attr}>
|
||||||
<tbody>
|
<tbody>
|
||||||
${results.data.map(d => `<tr>
|
${results.data.map(d => `<tr>
|
||||||
${d.map(f => `<td>${f}</td>`).join('')}
|
${d.map(f => `<td>${escapeHTML(f)}</td>`).join('')}
|
||||||
</tr>`).join('')}
|
</tr>`).join('')}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>`
|
</table>`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user