fcnGenericHash(): emit error message if request hash method isn't available

This commit is contained in:
Even Rouault 2019-10-26 23:42:37 +02:00
parent 6665fe0621
commit 6c02dbab22
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D
2 changed files with 5 additions and 1 deletions

View File

@ -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;
}

View File

@ -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" );