Skip to content

Commit

Permalink
fcnGenericHash(): emit error message if request hash method isn't ava…
Browse files Browse the repository at this point in the history
…ilable
  • Loading branch information
rouault committed Oct 27, 2019
1 parent 6665fe0 commit 6c02dba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -5065,6 +5065,10 @@ static QVariant fcnGenericHash( const QVariantList &values, const QgsExpressionC
hash = fcnHash( str, QCryptographicHash::Keccak_512 );
}
#endif
else
{
parent->setEvalErrorString( QObject::tr( "Hash method %1 is not available on this system." ).arg( str ) );
}
return hash;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsexpression.cpp
Expand Up @@ -1476,7 +1476,7 @@ class TestQgsExpression: public QObject
QTest::newRow( "md5('QGIS')" ) << QStringLiteral( "md5('QGIS')" ) << false << QVariant( "57470aaa9e22adaefac7f5f342f1c6da" );
QTest::newRow( "sha256(NULL)" ) << QStringLiteral( "sha256(NULL)" ) << false << QVariant( );
QTest::newRow( "sha256('QGIS')" ) << QStringLiteral( "sha256('QGIS')" ) << false << QVariant( "eb045cba7a797aaa06ac58830846e40c8e8c780bc0676d3393605fae50c05309" );
QTest::newRow( "hash('QGIS', 'qsdf')" ) << QStringLiteral( "hash('QGIS', 'qsdf')" ) << false << QVariant();
QTest::newRow( "hash('QGIS', 'qsdf')" ) << QStringLiteral( "hash('QGIS', 'qsdf')" ) << true << QVariant();
QTest::newRow( "hash('QGIS', 'md4')" ) << QStringLiteral( "hash('QGIS', 'md4')" ) << false << QVariant( "c0fc71c241cdebb6e888cbac0e2b68eb" );
QTest::newRow( "hash('QGIS', 'md5')" ) << QStringLiteral( "hash('QGIS', 'md5')" ) << false << QVariant( "57470aaa9e22adaefac7f5f342f1c6da" );
QTest::newRow( "hash('QGIS', 'sha1')" ) << QStringLiteral( "hash('QGIS', 'sha1')" ) << false << QVariant( "f87cfb2b74cdd5867db913237024e7001e62b114" );
Expand Down

0 comments on commit 6c02dba

Please sign in to comment.