fix: don't create files with bad names
This commit is contained in:
parent
43278ee35d
commit
6d446ba1b6
@ -59,7 +59,8 @@ class SDStatementAction(name: String) : DumbAwareAction(name) {
|
|||||||
CoroutineScope(Job() + Dispatchers.IO).launch {
|
CoroutineScope(Job() + Dispatchers.IO).launch {
|
||||||
val data = SDom.downloadProblemStatement(contest, problem)
|
val data = SDom.downloadProblemStatement(contest, problem)
|
||||||
fun createTmpFile(): Path {
|
fun createTmpFile(): Path {
|
||||||
val path = Files.createTempFile("${problem.name}_${contest.name}", ".pdf")
|
val prefix = "${problem.name}_${contest.name}".replace("[^a-zA-Z0-9._-]".toRegex(), "_")
|
||||||
|
val path = Files.createTempFile(prefix, ".pdf")
|
||||||
Files.write(path, data, StandardOpenOption.WRITE)
|
Files.write(path, data, StandardOpenOption.WRITE)
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user