Browse Source

CPP: Fixing crash when AsYouTypeFormatter tries to handle countries with long numbers.

pull/567/head
Vonage Holdings Corp 13 years ago
committed by Mihaela Rosca
parent
commit
4a597371da
4 changed files with 551 additions and 550 deletions
  1. +1
    -0
      AUTHORS
  2. +8
    -8
      cpp/src/phonenumbers/asyoutypeformatter.cc
  3. +541
    -541
      cpp/src/phonenumbers/test_metadata.cc
  4. +1
    -1
      resources/PhoneNumberMetaDataForTesting.xml

+ 1
- 0
AUTHORS View File

@ -1,3 +1,4 @@
Google Inc.
Vonage Holdings Corp.
Ian Galpin
Ben Gertzfield

+ 8
- 8
cpp/src/phonenumbers/asyoutypeformatter.cc View File

@ -68,25 +68,25 @@ const char kNationalPrefixSeparatorsPattern[] = "[- ]";
void ReplacePatternDigits(string* pattern) {
DCHECK(pattern);
string new_pattern;
bool is_in_braces = false;
for (string::const_iterator it = pattern->begin(); it != pattern->end();
++it) {
const char current_char = *it;
if (isdigit(current_char)) {
if (it + 1 != pattern->end()) {
const char next_char = it[1];
if (next_char != ',' && next_char != '}') {
new_pattern += "\\d";
} else {
new_pattern += current_char;
}
if (is_in_braces) {
new_pattern += current_char;
} else {
new_pattern += "\\d";
}
} else {
new_pattern += current_char;
if (current_char == '{') {
is_in_braces = true;
} else if (current_char == '}') {
is_in_braces = false;
}
}
}
pattern->assign(new_pattern);


+ 541
- 541
cpp/src/phonenumbers/test_metadata.cc
File diff suppressed because it is too large
View File


+ 1
- 1
resources/PhoneNumberMetaDataForTesting.xml View File

@ -232,7 +232,7 @@
<leadingDigits>2|3[3-9]|906|[4-9][1-9]1</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d{2})(\d{4,9})">
<numberFormat pattern="(\d{2})(\d{4,11})">
<leadingDigits>[34]0|[68]9</leadingDigits>
<format>$1/$2</format>
</numberFormat>


Loading…
Cancel
Save