From 649ee12aba2ee92781f0ab888d21a1bdb440b7da Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Fri, 14 Dec 2018 20:59:55 +0100 Subject: QRegularExpression: anchor wildcard pattern The current implementation of wildcardToRegularExpression doesn't anchor the pattern which makes it not narrow enough for globbing patterns. This patch fixes that by applying anchoredPattern before returning the wildcard pattern. [ChangeLog][QtCore][QRegularExpression] The wildcardToRegularExpression method now returns a properly anchored pattern. Change-Id: I7bee73389d408cf42499652e4fb854517a8125b5 Fixes: QTBUG-72539 Reviewed-by: Thiago Macieira --- src/corelib/io/qdir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib/io/qdir.cpp') diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 7df461ddce..3007ffb958 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2127,10 +2127,9 @@ QString QDir::rootPath() bool QDir::match(const QStringList &filters, const QString &fileName) { for (QStringList::ConstIterator sit = filters.constBegin(); sit != filters.constEnd(); ++sit) { - QString wildcard = QRegularExpression::wildcardToRegularExpression(*sit); // Insensitive exact match // (see Notes for QRegExp Users in QRegularExpression's documentation) - QRegularExpression rx(QRegularExpression::anchoredPattern(wildcard), + QRegularExpression rx(QRegularExpression::wildcardToRegularExpression(*sit), QRegularExpression::CaseInsensitiveOption); if (rx.match(fileName).hasMatch()) return true; -- cgit v1.2.3