Skip to content

Commit fe6e967

Browse files
committedMar 6, 2018
[processing] Fix invalid filenames are used for temporary files
during models Fixes #18263 (cherry-picked from 84cdd6)
1 parent d43db07 commit fe6e967

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎src/core/processing/qgsprocessingutils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "qgsprocessingalgorithm.h"
2828
#include "qgsvectorlayerfeatureiterator.h"
2929
#include "qgsexpressioncontextscopegenerator.h"
30+
#include "qgsfileutils.h"
3031

3132
QList<QgsRasterLayer *> QgsProcessingUtils::compatibleRasterLayers( QgsProject *project, bool sort )
3233
{
@@ -539,7 +540,7 @@ QString QgsProcessingUtils::generateTempFilename( const QString &basename )
539540
QDir tmpDir;
540541
tmpDir.mkdir( path );
541542
}
542-
return path + '/' + basename;
543+
return path + '/' + QgsFileUtils::stringToSafeFilename( basename );
543544
}
544545

545546
QString QgsProcessingUtils::formatHelpMapAsHtml( const QVariantMap &map, const QgsProcessingAlgorithm *algorithm )

‎tests/src/analysis/testqgsprocessing.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5797,6 +5797,11 @@ void TestQgsProcessing::tempUtils()
57975797
QVERIFY( tempFile1 != tempFile2 );
57985798
QVERIFY( tempFile2.endsWith( "test.txt" ) );
57995799
QVERIFY( tempFile2.startsWith( tempFolder ) );
5800+
5801+
// invalid characters
5802+
QString tempFile3 = QgsProcessingUtils::generateTempFilename( "mybad:file.txt" );
5803+
QVERIFY( tempFile3.endsWith( "mybad_file.txt" ) );
5804+
QVERIFY( tempFile3.startsWith( tempFolder ) );
58005805
}
58015806

58025807
void TestQgsProcessing::convertCompatible()

0 commit comments

Comments
 (0)
Please sign in to comment.