From 7bf5cc71dbc418b7a104aee596f815710d4eeed3 Mon Sep 17 00:00:00 2001 From: Blottiere Paul Date: Mon, 2 Oct 2023 10:29:29 +0200 Subject: [PATCH] Add safeguard for -of option --- python/plugins/processing/algs/gdal/warp.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/plugins/processing/algs/gdal/warp.py b/python/plugins/processing/algs/gdal/warp.py index 00bb168ccff7..71b66b015117 100644 --- a/python/plugins/processing/algs/gdal/warp.py +++ b/python/plugins/processing/algs/gdal/warp.py @@ -226,8 +226,13 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True): out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context) self.setOutputValue(self.OUTPUT, out) + + output_format = QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1]) + if not output_format: + raise QgsProcessingException(self.tr('Output format is invalid')) + arguments.append('-of') - arguments.append(QgsRasterFileWriter.driverForExtension(os.path.splitext(out)[1])) + arguments.append(output_format) options = self.parameterAsString(parameters, self.OPTIONS, context) if options: