diff options
author | Zeno Albisser <zeno.albisser@nokia.com> | 2010-06-15 11:39:25 (GMT) |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2010-06-15 13:05:21 (GMT) |
commit | 20a39c16f236f999cd1694cdc47a3739efcbbfe4 (patch) | |
tree | 2a12f3ecd842165fb0e9e2380f892fe1fa391b57 | |
parent | 2cb5d8f7425bce83b5e95925e15d7920be3d2e8d (diff) | |
download | Qt-20a39c16f236f999cd1694cdc47a3739efcbbfe4.zip Qt-20a39c16f236f999cd1694cdc47a3739efcbbfe4.tar.gz Qt-20a39c16f236f999cd1694cdc47a3739efcbbfe4.tar.bz2 |
Temporary fix for regression in QSslCertificate::fromPath()
The regression was introduced with 164f347aba7287407615223dc2219a016ebc8248.
As soon as possible we should probably rewrite the fromPath() function,
to have a proper solution.
Nevertheless this might be a bigger change and should not be done
so late in release cycle.
Reviewed-by: TrustMe
-rw-r--r-- | src/network/ssl/qsslcertificate.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qsslcertificate/tst_qsslcertificate.cpp | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index ed12e00..a3ea555 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -537,7 +537,7 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path, // $, (,), *, +, ., ?, [, ,], ^, {, | and }. int pos = -1; if (syntax == QRegExp::Wildcard) - pos = path.indexOf(QRegExp(QLatin1String("[\\*\\?\\[]"))); + pos = path.indexOf(QRegExp(QLatin1String("[^\\][\\*\\?\\[\\]]"))); else if (syntax != QRegExp::FixedString) pos = path.indexOf(QRegExp(QLatin1String("[^\\][\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\}\\|]"))); QString pathPrefix = path.left(pos); // == path if pos < 0 @@ -548,8 +548,13 @@ QList<QSslCertificate> QSslCertificate::fromPath(const QString &path, // chop off the first two characters from the glob'ed paths. int startIndex = 0; if (pathPrefix.trimmed().isEmpty()) { - startIndex = 2; - pathPrefix = QLatin1String("."); + if(path.startsWith(QLatin1Char('/'))) { + pathPrefix = path.left(path.indexOf(QRegExp(QLatin1String("[\\*\\?\\[]")))); + pathPrefix = path.left(path.lastIndexOf(QLatin1Char('/'))); + } else { + startIndex = 2; + pathPrefix = QLatin1String("."); + } } // The path is a file. diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp index 505b867..d0509bb 100644 --- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp @@ -542,6 +542,9 @@ void tst_QSslCertificate::fromPath_data() QTest::newRow("\"d.*/c.*.pem\" regexp der") << QString("d.*/c.*.pem") << int(QRegExp::RegExp) << false << 0; QTest::newRow("\"d.*/c.*.pem\" wildcard pem") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << true << 0; QTest::newRow("\"d.*/c.*.pem\" wildcard der") << QString("d.*/c.*.pem") << int(QRegExp::Wildcard) << false << 0; +#ifdef Q_OS_LINUX + QTest::newRow("absolute path wildcard pem") << QString(QDir::currentPath() + "/certificates/*.pem") << int(QRegExp::Wildcard) << true << 4; +#endif QTest::newRow("trailing-whitespace") << QString("more-certificates/trailing-whitespace.pem") << int(QRegExp::FixedString) << true << 1; QTest::newRow("no-ending-newline") << QString("more-certificates/no-ending-newline.pem") << int(QRegExp::FixedString) << true << 1; |