bool StringParser::IsValidEmailAddress(const String &sEmailAddress) { // Original: [^<>" ]+@[^<>" ]+\.[^<>" ]+ // // Rule set: // - Don't allow spaces anywhere in the address. // - Don't allow < or > or " anywhere. // // Temp fix for moontear noreply@workflow hard coded invalid domain issue // Less strict requires no suffix for localhost or noreply@workflow regularExpression = "[^<>\" ]+@[^<>\" ]+" String sValidEmailPattern = IniFileSettings::Instance()->GetValidEmailPattern(); String regularExpression; // Override default pattern if one is defined if (sValidEmailPattern.empty()) regularExpression = "[^<>\" ]+@[^<>\" ]+\\.[^<>\" ]+"; else regularExpression = sValidEmailPattern; RegularExpression regexpEvaluator; bool result = regexpEvaluator.TestExactMatch(regularExpression, sEmailAddress); return result; }
bool StringParser::IsValidDomainName(const String &sDomainName) { // Original: ^(\[([0-9]{1,3}\.){3}[0-9]{1,3}\]|(?=.{1,255}$)((?!-|\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9])(|\.(?!-|\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]){1,126})$ // Conversion: // 1) Replace \ with \\ // 2) Replace " with \" String regularExpression = "^(\\[([0-9]{1,3}\\.){3}[0-9]{1,3}\\]|(?=.{1,255}$)((?!-|\\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9])(|\\.(?!-|\\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]){1,126})$"; RegularExpression regexpEvaluator; bool result = regexpEvaluator.TestExactMatch(regularExpression, sDomainName); return result; }
bool StringParser::IsValidEmailAddress(const String &sEmailAddress) { // Original: ^(("[^<>@\\]+")|([^<> @\\"]+))@(\[([0-9]{1,3}\.){3}[0-9]{1,3}\]|(?=.{1,255}$)((?!-|\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9])(|\.(?!-|\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]){1,126})$ // // Conversion: // 1) Replace \ with \\ // 2) Replace " with \" String regularExpression = "^((\"[^<>@\\\\]+\")|([^<> @\\\\\"]+))@(\\[([0-9]{1,3}\\.){3}[0-9]{1,3}\\]|(?=.{1,255}$)((?!-|\\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9])(|\\.(?!-|\\.)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]){1,126})$"; RegularExpression regexpEvaluator; bool result = regexpEvaluator.TestExactMatch(regularExpression, sEmailAddress); return result; }
bool StringParser::WildcardMatch(const String &pattern, const String &value) { // Convert the pattern to a regular expression. String regularExpression; for (int i = 0; i < pattern.GetLength(); i++) { wchar_t c = pattern[i]; switch (c) { case '\\': case '|': case '.': case '^': case '$': case '+': case '(': case ')': case '[': case ']': case '{': case '}': regularExpression.append(_T("\\")); regularExpression += c; break; case '*': regularExpression.append(_T(".*")); break; case '?': regularExpression.append(_T(".")); break; default: regularExpression += c; break; } } RegularExpression regexpEvaluator; bool result = regexpEvaluator.TestExactMatch(regularExpression, value); return result; }