Fixed bug in implementation of isStringEqualNoCase().

This commit is contained in:
Vincent Richard 2018-09-06 00:16:48 +02:00
parent 258f943ded
commit 7e29cf01fa
2 changed files with 4 additions and 1 deletions

View File

@ -62,7 +62,7 @@ bool stringUtils::isStringEqualNoCase(const string& s1, const string& s2) {
bool equal = true;
const string::const_iterator end = s1.end();
for (string::const_iterator i = s1.begin(), j = s2.begin(); i != end ; ++i, ++j) {
for (string::const_iterator i = s1.begin(), j = s2.begin() ; equal && i != end ; ++i, ++j) {
equal = (fac.tolower(static_cast <unsigned char>(*i)) == fac.tolower(static_cast <unsigned char>(*j)));
}

View File

@ -98,6 +98,9 @@ VMIME_TEST_SUITE_BEGIN(stringUtilsTest)
VASSERT_EQ("1", true, stringUtils::isStringEqualNoCase(vmime::string("foo"), vmime::string("foo")));
VASSERT_EQ("2", true, stringUtils::isStringEqualNoCase(vmime::string("FOo"), vmime::string("foo")));
VASSERT_EQ("3", true, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("FOo")));
VASSERT_EQ("4", false, stringUtils::isStringEqualNoCase(vmime::string("foO"), vmime::string("bar")));
VASSERT_EQ("5", false, stringUtils::isStringEqualNoCase(vmime::string("foOO"), vmime::string("barO")));
}
void testIsStringEqualNoCase3() {