Skip to content
Permalink
Browse files

[processing] Fix invalid filenames are used for temporary files

during models

Fixes #18263
  • Loading branch information
nyalldawson committed Mar 5, 2018
1 parent 8543a91 commit 84cdd609abcbc925a7a177a7fd2bb43059c55c13
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 84cdd60

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