Commit f5ee30f6 authored by atwilson@chromium.org's avatar atwilson@chromium.org

Gracefully handle icu errors when checking for enterprise domains.

We shouldn't ever get ICU errors when checking for enterprise domains, but
apparently they do happen out in the field. Instead of crashing, we instead
gracefully handle errors by treating domains in that case as potential
enterprise domains (skipping the optimization).

BUG=365351

Review URL: https://codereview.chromium.org/386573002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282347 0039d316-1c4b-4281-b951-d872f2087c98
parent a2e1f2ee
......@@ -44,7 +44,16 @@ bool MatchDomain(const base::string16& domain, const base::string16& pattern) {
UErrorCode status = U_ZERO_ERROR;
const icu::UnicodeString icu_pattern(pattern.data(), pattern.length());
icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status);
DCHECK(U_SUCCESS(status)) << "Invalid domain pattern: " << pattern;
if (!U_SUCCESS(status)) {
// http://crbug.com/365351 - if for some reason the matcher creation fails
// just return that the pattern doesn't match the domain. This is safe
// because the calling method (IsNonEnterpriseUser()) is just used to enable
// an optimization for non-enterprise users - better to skip the
// optimization than crash.
DLOG(ERROR) << "Possible invalid domain pattern: " << pattern
<< " - Error: " << status;
return false;
}
icu::UnicodeString icu_input(domain.data(), domain.length());
matcher.reset(icu_input);
status = U_ZERO_ERROR;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment