summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qregexp.cpp2
-rw-r--r--tests/auto/qregexp/tst_qregexp.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index ca2d07c..109ae94 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -772,7 +772,7 @@ static QString wc2rx(const QString &wc_str, const bool enableEscaping)
if (isEscaping) {
rx += QLatin1String("\\\\");
} // we insert the \\ later if necessary
- if (i+1 == wclen) { // the end
+ if (i == wclen) { // the end
rx += QLatin1String("\\\\");
}
} else {
diff --git a/tests/auto/qregexp/tst_qregexp.cpp b/tests/auto/qregexp/tst_qregexp.cpp
index 6a4b38e..d444558 100644
--- a/tests/auto/qregexp/tst_qregexp.cpp
+++ b/tests/auto/qregexp/tst_qregexp.cpp
@@ -938,6 +938,8 @@ void tst_QRegExp::testEscapingWildcard_data(){
QTest::newRow("? Escaped") << "\\?O;" << "?O;" << true;
QTest::newRow("[] not escaped") << "[lL]" << "l" << true;
+ QTest::newRow("[] escaped") << "\\[\\]" << "[]" << true;
+
QTest::newRow("case [[]") << "[[abc]" << "[" << true;
QTest::newRow("case []abc] match ]") << "[]abc]" << "]" << true;
QTest::newRow("case []abc] match a") << "[]abc]" << "a" << true;
@@ -953,7 +955,7 @@ void tst_QRegExp::testEscapingWildcard_data(){
QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true;
QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true;
- QTest::newRow("a '\\' at the end") << "\\\\Qt;" << "\\\\Qt;" << true;
+ QTest::newRow("a '\\' at the end") << "\\\\Qt;\\" << "\\\\Qt;\\" << true;
}
void tst_QRegExp::testEscapingWildcard(){