Fix phone number parsing crash

This commit is contained in:
Niels Andriesse 2019-04-29 11:34:11 +10:00
parent e4de406be6
commit c429bebaba
5 changed files with 17 additions and 11 deletions

View File

@ -31,7 +31,7 @@ final class OnboardingAccountDetailsViewController : OnboardingBaseViewControlle
let titleLabel = self.createTitleLabel(text: NSLocalizedString("Create Your Loki Messenger Account", comment: ""))
titleLabel.accessibilityIdentifier = "onboarding.accountDetailsStep.titleLabel"
let topSpacer = UIView.vStretchingSpacer()
let displayNameLabel = createExplanationLabel(text: NSLocalizedString("Enter a name that will be shown to all your contacts", comment: ""))
let displayNameLabel = createExplanationLabel(text: NSLocalizedString("Enter a name to be shown to your contacts", comment: ""))
displayNameLabel.accessibilityIdentifier = "onboarding.accountDetailsStep.displayNameLabel"
let passwordLabel = createExplanationLabel(text: NSLocalizedString("Type an optional password for added security", comment: ""))
passwordLabel.accessibilityIdentifier = "onboarding.accountDetailsStep.passwordLabel"

View File

@ -19,7 +19,7 @@ public class OnboardingPermissionsViewController: OnboardingBaseViewController {
target: self,
action: #selector(skipWasPressed))
let titleLabel = self.createTitleLabel(text: NSLocalizedString("ONBOARDING_PERMISSIONS_TITLE", comment: "Title of the 'onboarding permissions' view."))
let titleLabel = self.createTitleLabel(text: NSLocalizedString("Loki Messenger can let you know when you get a message (and who it is from)", comment: ""))
titleLabel.accessibilityIdentifier = "onboarding.permissions." + "titleLabel"
let explanationLabel = self.createExplanationLabel(text: NSLocalizedString("ONBOARDING_PERMISSIONS_EXPLANATION",

View File

@ -28,7 +28,7 @@ final class OnboardingPublicKeyViewController : OnboardingBaseViewController {
let titleLabel = createTitleLabel(text: NSLocalizedString("Create Your Loki Messenger Account", comment: ""))
titleLabel.accessibilityIdentifier = "onboarding.publicKeyStep.titleLabel"
let topSpacer = UIView.vStretchingSpacer()
let explanationLabel = createExplanationLabel(text: NSLocalizedString("Please save the seed below in a safe location. They can be used to restore your account if you lose access or migrate to a new device.", comment: ""))
let explanationLabel = createExplanationLabel(text: NSLocalizedString("Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device.", comment: ""))
explanationLabel.accessibilityIdentifier = "onboarding.publicKeyStep.explanationLabel"
let bottomSpacer = UIView.vStretchingSpacer()
let registerButton = button(title: NSLocalizedString("Register", comment: ""), selector: #selector(register))

View File

@ -2545,10 +2545,11 @@
// -- Loki --
"Loki Messenger can let you know when you get a message (and who it is from)" = "Loki Messenger can let you know when you get a message (and who it is from)";
"Create Your Loki Messenger Account" = "Create Your Loki Messenger Account";
"Enter a name that will be shown to all your contacts" = "Enter a name that will be shown to all your contacts";
"Enter a name to be shown to your contacts" = "Enter a name to be shown to your contacts";
"Display Name (Optional)" = "Display Name (Optional)";
"Type an optional password for added security" = "Type an optional password for added security";
"Password (Optional)" = "Password (Optional)";
"Please save the seed below in a safe location. They can be used to restore your account if you lose access or migrate to a new device." = "Please save the seed below in a safe location. They can be used to restore your account if you lose access or migrate to a new device.";
"Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device." = "Please save the seed below in a safe location. It can be used to restore your account if you lose access, or to migrate to a new device.";
"Register" = "Register";

View File

@ -89,12 +89,17 @@ static NSString *const RPDefaultsKeyPhoneNumberCanonical = @"RPDefaultsKeyPhoneN
}
+ (nullable PhoneNumber *)phoneNumberFromE164:(NSString *)text {
OWSAssertDebug(text != nil);
OWSAssertDebug([text hasPrefix:COUNTRY_CODE_PREFIX]);
PhoneNumber *number = [PhoneNumber phoneNumberFromText:text andRegion:@"ZZ"];
OWSAssertDebug(number != nil);
return number;
NSString *e164 = text;
PhoneNumber *result = [[PhoneNumber alloc] initWithPhoneNumber:[NBPhoneNumber new] e164:e164];
return result;
// Original code:
// ========
// OWSAssertDebug(text != nil);
// OWSAssertDebug([text hasPrefix:COUNTRY_CODE_PREFIX]);
// PhoneNumber *number = [PhoneNumber phoneNumberFromText:text andRegion:@"ZZ"];
// OWSAssertDebug(number != nil);
// return number;
// ========
}
+ (NSString *)bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:(NSString *)input {