Fix a couple of edge cases for WildcardUnix matching
Fix a couple of cases where WildcardUnix was not matching when the string was just [] or ended with a \. The testWildcardEscaping() test has been extended to account for these two cases too. Integrate 7ce3726aea4be2dfdb57966a4482f66fec6f8f57 from 4.8 Task-number: QTBUG-20897 Change-Id: I7a07ac008473fa7a080db752e189f6404842603f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
4dae8c1aff
commit
8eb2546bf2
@ -773,7 +773,7 @@ static QString wc2rx(const QString &wc_str, const bool enableEscaping)
|
|||||||
if (isEscaping) {
|
if (isEscaping) {
|
||||||
rx += QLatin1String("\\\\");
|
rx += QLatin1String("\\\\");
|
||||||
} // we insert the \\ later if necessary
|
} // we insert the \\ later if necessary
|
||||||
if (i+1 == wclen) { // the end
|
if (i == wclen) { // the end
|
||||||
rx += QLatin1String("\\\\");
|
rx += QLatin1String("\\\\");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -829,6 +829,8 @@ void tst_QRegExp::testEscapingWildcard_data(){
|
|||||||
QTest::newRow("? Escaped") << "\\?O;" << "?O;" << true;
|
QTest::newRow("? Escaped") << "\\?O;" << "?O;" << true;
|
||||||
|
|
||||||
QTest::newRow("[] not escaped") << "[lL]" << "l" << true;
|
QTest::newRow("[] not escaped") << "[lL]" << "l" << true;
|
||||||
|
QTest::newRow("[] escaped") << "\\[\\]" << "[]" << true;
|
||||||
|
|
||||||
QTest::newRow("case [[]") << "[[abc]" << "[" << true;
|
QTest::newRow("case [[]") << "[[abc]" << "[" << true;
|
||||||
QTest::newRow("case []abc] match ]") << "[]abc]" << "]" << true;
|
QTest::newRow("case []abc] match ]") << "[]abc]" << "]" << true;
|
||||||
QTest::newRow("case []abc] match a") << "[]abc]" << "a" << true;
|
QTest::newRow("case []abc] match a") << "[]abc]" << "a" << true;
|
||||||
@ -844,7 +846,7 @@ void tst_QRegExp::testEscapingWildcard_data(){
|
|||||||
|
|
||||||
QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true;
|
QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true;
|
||||||
QTest::newRow("two 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(){
|
void tst_QRegExp::testEscapingWildcard(){
|
||||||
|
Loading…
Reference in New Issue
Block a user