summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@idiap.ch>2018-12-14 20:59:55 +0100
committerSamuel Gaist <samuel.gaist@idiap.ch>2018-12-15 13:24:16 +0000
commit649ee12aba2ee92781f0ab888d21a1bdb440b7da (patch)
treee6217e716b5848bee147f76edac18b0585490968 /src/corelib
parente80bf655e922e9864f8843b5e7bbb47019a6d95a (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qdir.cpp3
-rw-r--r--src/corelib/tools/qregularexpression.cpp2
2 files changed, 2 insertions, 3 deletions
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;
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 908e7ff0d6..831fa28de0 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -1992,7 +1992,7 @@ QString QRegularExpression::wildcardToRegularExpression(const QString &pattern)
}
}
- return rx;
+ return anchoredPattern(rx);
}
/*!