Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2022-05-29 00:40:05 +0300
committerdartcafe <github@dartcafe.de>2022-05-29 00:40:05 +0300
commitc1f08438e543724ba302431bc5a62a010cc7903a (patch)
tree357c7210a5cd2cdfe67f795d2d1eb6bd401f3126 /src
parent5e82ad3c654c3a7efae3e1a5dae076521e0cda32 (diff)
strip illegal characters from sheet name
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src')
-rw-r--r--src/js/components/Export/ExportPoll.vue13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/js/components/Export/ExportPoll.vue b/src/js/components/Export/ExportPoll.vue
index 46be3028..2adb0ca7 100644
--- a/src/js/components/Export/ExportPoll.vue
+++ b/src/js/components/Export/ExportPoll.vue
@@ -98,6 +98,14 @@ export default {
votes: (state) => state.votes,
isOwner: (state) => state.poll.acl.allowEdit,
}),
+
+ sheetName() {
+ // Not allowed characters for the sheet name: : \ / ? * [ ]
+ // Strip them out
+ // Stonger regex i.e. for file names: /[&/\\#,+()$~%.'":*?<>{}]/g
+ const regex = /[\\/?*[\]]/g
+ return this.poll.title.replaceAll(regex, '').slice(0, 31)
+ },
},
methods: {
@@ -106,7 +114,7 @@ export default {
const fromHeader = [t('polls', 'From')]
const toHeader = [t('polls', 'To')]
this.workBook = xlsxUtils.book_new()
- this.workBook.SheetNames.push(this.poll.title.slice(0, 31))
+ this.workBook.SheetNames.push(this.sheetName)
this.sheetData = []
if (['html', 'xlsx', 'ods'].includes(type)) {
@@ -160,6 +168,7 @@ export default {
} else {
this.addVotesArray()
}
+
const workBookOutput = xlsxWrite(this.workBook, { bookType: type, type: 'binary' })
saveAs(new Blob([this.s2ab(workBookOutput)], { type: 'application/octet-stream' }), `poll.${type}`)
},
@@ -185,7 +194,7 @@ export default {
})
const workSheet = xlsxUtils.aoa_to_sheet(this.sheetData)
- this.workBook.Sheets[this.poll.title.slice(0, 31)] = workSheet
+ this.workBook.Sheets[this.sheetName] = workSheet
},
s2ab(s) {