| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/l10n/l10n_util.h" | 5 #include "ui/base/l10n/l10n_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstdlib> | 8 #include <cstdlib> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 size_t equals_loc = keywords.find("="); | 607 size_t equals_loc = keywords.find("="); |
| 608 if (equals_loc == std::string::npos || | 608 if (equals_loc == std::string::npos || |
| 609 equals_loc < 1 || equals_loc > keywords.size() - 2) | 609 equals_loc < 1 || equals_loc > keywords.size() - 2) |
| 610 return false; | 610 return false; |
| 611 } | 611 } |
| 612 | 612 |
| 613 // Check that all characters before the at-sign are alphanumeric or | 613 // Check that all characters before the at-sign are alphanumeric or |
| 614 // underscore. | 614 // underscore. |
| 615 for (size_t i = 0; i < prefix.size(); i++) { | 615 for (size_t i = 0; i < prefix.size(); i++) { |
| 616 char ch = prefix[i]; | 616 char ch = prefix[i]; |
| 617 if (!IsAsciiAlpha(ch) && !IsAsciiDigit(ch) && ch != '_') | 617 if (!base::IsAsciiAlpha(ch) && !base::IsAsciiDigit(ch) && ch != '_') |
| 618 return false; | 618 return false; |
| 619 } | 619 } |
| 620 | 620 |
| 621 // Check that the initial token (before the first hyphen/underscore) | 621 // Check that the initial token (before the first hyphen/underscore) |
| 622 // is 1 - 3 alphabetical characters (a language tag). | 622 // is 1 - 3 alphabetical characters (a language tag). |
| 623 for (size_t i = 0; i < prefix.size(); i++) { | 623 for (size_t i = 0; i < prefix.size(); i++) { |
| 624 char ch = prefix[i]; | 624 char ch = prefix[i]; |
| 625 if (ch == '_') { | 625 if (ch == '_') { |
| 626 if (i < 1 || i > 3) | 626 if (i < 1 || i > 3) |
| 627 return false; | 627 return false; |
| 628 break; | 628 break; |
| 629 } | 629 } |
| 630 if (!IsAsciiAlpha(ch)) | 630 if (!base::IsAsciiAlpha(ch)) |
| 631 return false; | 631 return false; |
| 632 } | 632 } |
| 633 | 633 |
| 634 // Check that the all tokens after the initial token are 1 - 8 characters. | 634 // Check that the all tokens after the initial token are 1 - 8 characters. |
| 635 // (Tokenize/StringTokenizer don't work here, they collapse multiple | 635 // (Tokenize/StringTokenizer don't work here, they collapse multiple |
| 636 // delimiters into one.) | 636 // delimiters into one.) |
| 637 int token_len = 0; | 637 int token_len = 0; |
| 638 int token_index = 0; | 638 int token_index = 0; |
| 639 for (size_t i = 0; i < prefix.size(); i++) { | 639 for (size_t i = 0; i < prefix.size(); i++) { |
| 640 if (prefix[i] != '_') { | 640 if (prefix[i] != '_') { |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 | 873 |
| 874 const char* const* GetAcceptLanguageListForTesting() { | 874 const char* const* GetAcceptLanguageListForTesting() { |
| 875 return kAcceptLanguageList; | 875 return kAcceptLanguageList; |
| 876 } | 876 } |
| 877 | 877 |
| 878 size_t GetAcceptLanguageListSizeForTesting() { | 878 size_t GetAcceptLanguageListSizeForTesting() { |
| 879 return arraysize(kAcceptLanguageList); | 879 return arraysize(kAcceptLanguageList); |
| 880 } | 880 } |
| 881 | 881 |
| 882 } // namespace l10n_util | 882 } // namespace l10n_util |
| OLD | NEW |