diff options
author | benchan <benchan@chromium.org> | 2014-09-04 22:08:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-05 05:11:01 +0000 |
commit | 57d121ace54a34516a4b758007632ac410dfe9bd (patch) | |
tree | acfd2abed491b181c45163491f0025f84a2e6051 /base/guid.cc | |
parent | 5b9e04fc7c694535d2cc21710d7f7c688700648f (diff) | |
download | chromium_src-57d121ace54a34516a4b758007632ac410dfe9bd.zip chromium_src-57d121ace54a34516a4b758007632ac410dfe9bd.tar.gz chromium_src-57d121ace54a34516a4b758007632ac410dfe9bd.tar.bz2 |
Make base::IsValidGUID() accept GUID strings in lowercase.
It's pretty common that GUID strings express hex digits in lowercase.
This CL modifies base::IsValidGUID() to also accept GUID strings in
lowercase, so that the function can be used to validate GUIDs not
generated by base::GenerateGUID().
BUG=None
TEST=base_unittests
Review URL: https://codereview.chromium.org/546603002
Cr-Commit-Position: refs/heads/master@{#293449}
Diffstat (limited to 'base/guid.cc')
-rw-r--r-- | base/guid.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/base/guid.cc b/base/guid.cc index b7d79f2..be5c58b 100644 --- a/base/guid.cc +++ b/base/guid.cc @@ -4,6 +4,8 @@ #include "base/guid.h" +#include "base/strings/string_util.h" + namespace base { bool IsValidGUID(const std::string& guid) { @@ -11,14 +13,13 @@ bool IsValidGUID(const std::string& guid) { if (guid.length() != kGUIDLength) return false; - const std::string hexchars = "0123456789ABCDEF"; - for (uint32 i = 0; i < guid.length(); ++i) { + for (size_t i = 0; i < guid.length(); ++i) { char current = guid[i]; if (i == 8 || i == 13 || i == 18 || i == 23) { if (current != '-') return false; } else { - if (hexchars.find(current) == std::string::npos) + if (!IsHexDigit(current)) return false; } } |