Filter out disallowed characters from job name

Took a while to figure out exactly what to do here. But the task itself is simple.
The Ultimaker software apparently doesn't accept special characters here. The regex here is exactly the inverse of the regex that they use to accept job names.

Done as a 5 minute fix.
This commit is contained in:
Ghostkeeper 2021-04-14 16:56:17 +02:00
parent db74bbda60
commit adb5f28aaf
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,6 +1,7 @@
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import re # Filtering out invalid characters.
from typing import List, Optional
from UM.FileHandler.FileHandler import FileHandler
@ -27,6 +28,7 @@ class ExportFileJob(WriteFileJob):
# Determine the filename.
job_name = CuraApplication.getInstance().getPrintInformation().jobName
job_name = re.sub("[^\w\-. ()]", "-", job_name)
extension = self._mesh_format_handler.preferred_format.get("extension", "")
self.setFileName("{}.{}".format(job_name, extension))