Skip to content

Commit

Permalink
Merge pull request #1248 from EvanBldy/master
Browse files Browse the repository at this point in the history
[csv] add missing sanitize for some csv import + stop removing ';' an…
  • Loading branch information
NicoPennec authored Nov 23, 2023
2 parents 7ed4489 + f55793f commit 2717c70
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/pages/Breakdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,8 @@ export default {
uploadImportFile(data) {
const formData = new FormData()
const filename = 'import.csv'
const file = new File([data.join('\n')], filename, { type: 'text/csv' })
const csvContent = csv.turnEntriesToCsvString(data)
const file = new File([csvContent], filename, { type: 'text/csv' })
formData.append('file', file)
Expand Down
3 changes: 2 additions & 1 deletion src/components/pages/People.vue
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ export default {
uploadImportFile(data, toUpdate) {
const formData = new FormData()
const filename = 'import.csv'
const file = new File([data.join('\n')], filename, { type: 'text/csv' })
const csvContent = csv.turnEntriesToCsvString(data)
const file = new File([csvContent], filename, { type: 'text/csv' })
formData.append('file', file)
this.loading.importing = true
Expand Down
3 changes: 2 additions & 1 deletion src/components/pages/TaskType.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,8 @@ export default {
uploadImportFile(data) {
const formData = new FormData()
const filename = 'import.csv'
const file = new File([data.join('\n')], filename, { type: 'text/csv' })
const csvContent = csv.turnEntriesToCsvString(data)
const file = new File([csvContent], filename, { type: 'text/csv' })
formData.append('file', file)
Expand Down
4 changes: 1 addition & 3 deletions src/lib/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ const csv = {
entries.forEach(infoArray => {
const sanitizedCells = infoArray.map(cell => {
const cellString = `${cell || ''}`
if (cellString.search('"') !== -1) {
return `${cellString.replace(/;/g, '')}`
} else return `"${cellString}"`
return `"${cellString.replace(/"/g, '""')}"`
})
const line = sanitizedCells.join(';')
if (line.length > 2) lineArray.push(line)
Expand Down

0 comments on commit 2717c70

Please sign in to comment.