Skip to content
Permalink
Browse files

[processing] Fix invalid filenames are used for temporary files

during models

Fixes #18263

(cherry-picked from 84cdd6)
  • Loading branch information
nyalldawson committed Mar 3, 2018
1 parent d43db07 commit fe6e96731a6bfb7e500530406d82c26d0a838ef8
Showing with 7 additions and 1 deletion.
  1. +2 −1 src/core/processing/qgsprocessingutils.cpp
  2. +5 −0 tests/src/analysis/testqgsprocessing.cpp
@@ -27,6 +27,7 @@
#include "qgsprocessingalgorithm.h"
#include "qgsvectorlayerfeatureiterator.h"
#include "qgsexpressioncontextscopegenerator.h"
#include "qgsfileutils.h"

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

QString QgsProcessingUtils::formatHelpMapAsHtml( const QVariantMap &map, const QgsProcessingAlgorithm *algorithm )
@@ -5797,6 +5797,11 @@ void TestQgsProcessing::tempUtils()
QVERIFY( tempFile1 != tempFile2 );
QVERIFY( tempFile2.endsWith( "test.txt" ) );
QVERIFY( tempFile2.startsWith( tempFolder ) );

// invalid characters
QString tempFile3 = QgsProcessingUtils::generateTempFilename( "mybad:file.txt" );
QVERIFY( tempFile3.endsWith( "mybad_file.txt" ) );
QVERIFY( tempFile3.startsWith( tempFolder ) );
}

void TestQgsProcessing::convertCompatible()

0 comments on commit fe6e967

Please sign in to comment.
You can’t perform that action at this time.