From 351c8c00f0e252f466602e1345ea0a4e196969dd Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 22 Jun 2017 17:08:01 -0400 Subject: [PATCH 1/2] Remove phone number length limit in registration view. // FREEBIE --- Signal/src/ViewControllers/ViewControllerUtils.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Signal/src/ViewControllers/ViewControllerUtils.m b/Signal/src/ViewControllers/ViewControllerUtils.m index f88b8d648..51b33c143 100644 --- a/Signal/src/ViewControllers/ViewControllerUtils.m +++ b/Signal/src/ViewControllers/ViewControllerUtils.m @@ -49,12 +49,10 @@ NS_ASSUME_NONNULL_BEGIN NSString *center = insertionText.digitsOnly; // 4. Construct the "raw" new text by concatenating left, center and right. NSString *textAfterChange = [[left stringByAppendingString:center] stringByAppendingString:right]; - // 4a. Ensure we don't exceed the maximum length for a e164 phone number, - // 15 digits, per: https://en.wikipedia.org/wiki/E.164 - const int kMaxPhoneNumberLength = 15; - if (textAfterChange.length > kMaxPhoneNumberLength) { - textAfterChange = [textAfterChange substringToIndex:kMaxPhoneNumberLength]; - } + // NOTE: We can't ensure that the number does not exceed the maximum length for a e164 phone number, + // 15 digits, per: https://en.wikipedia.org/wiki/E.164 + // because "valid numbers in Germany have been assigned that are longer than this" per: + // https://github.com/googlei18n/libphonenumber/blob/master/FALSEHOODS.md // 5. Construct the "formatted" new text by inserting a hyphen if necessary. // reformat the phone number, trying to keep the cursor beside the inserted or deleted digit bool isJustDeletion = insertionText.length == 0; From 791c5bb89e641e2fffae18d99175cd8bb5110494 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 23 Jun 2017 09:34:02 -0400 Subject: [PATCH 2/2] Revise phone number length limit in registration view. // FREEBIE --- Signal/src/ViewControllers/ViewControllerUtils.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/ViewControllerUtils.m b/Signal/src/ViewControllers/ViewControllerUtils.m index 51b33c143..c70168018 100644 --- a/Signal/src/ViewControllers/ViewControllerUtils.m +++ b/Signal/src/ViewControllers/ViewControllerUtils.m @@ -49,10 +49,15 @@ NS_ASSUME_NONNULL_BEGIN NSString *center = insertionText.digitsOnly; // 4. Construct the "raw" new text by concatenating left, center and right. NSString *textAfterChange = [[left stringByAppendingString:center] stringByAppendingString:right]; - // NOTE: We can't ensure that the number does not exceed the maximum length for a e164 phone number, - // 15 digits, per: https://en.wikipedia.org/wiki/E.164 - // because "valid numbers in Germany have been assigned that are longer than this" per: + // 4a. Ensure we don't exceed the maximum length for a e164 phone number, + // 15 digits, per: https://en.wikipedia.org/wiki/E.164 + // + // NOTE: The actual limit is 18, not 15, because of certain invalid phone numbers in Germany. // https://github.com/googlei18n/libphonenumber/blob/master/FALSEHOODS.md + const int kMaxPhoneNumberLength = 18; + if (textAfterChange.length > kMaxPhoneNumberLength) { + textAfterChange = [textAfterChange substringToIndex:kMaxPhoneNumberLength]; + } // 5. Construct the "formatted" new text by inserting a hyphen if necessary. // reformat the phone number, trying to keep the cursor beside the inserted or deleted digit bool isJustDeletion = insertionText.length == 0;