pull/7/head
Niels Andriesse 6 years ago
parent 19a0d85afd
commit 4ce9228afd

@ -18,6 +18,7 @@
#import <SignalServiceKit/AppVersion.h> #import <SignalServiceKit/AppVersion.h>
#import <SignalServiceKit/PhoneNumberUtil.h> #import <SignalServiceKit/PhoneNumberUtil.h>
#import <SignalServiceKit/SignalAccount.h> #import <SignalServiceKit/SignalAccount.h>
#import <SignalServiceKit/SignalServiceKit-Swift.h>
#import <SignalServiceKit/TSAccountManager.h> #import <SignalServiceKit/TSAccountManager.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -396,16 +397,17 @@ NS_ASSUME_NONNULL_BEGIN
if (hasSearchText) { if (hasSearchText) {
// Loki: // Loki:
// ======== // ========
NSString *publicKey = self.searchBar.text;
// TODO: Validate public key and show an error if something's wrong
OWSTableSection *newConversationSection = [OWSTableSection new]; OWSTableSection *newConversationSection = [OWSTableSection new];
[newConversationSection [newConversationSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"Start a Conversation", @"") addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"Start a Conversation", @"")
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"start_conversation") accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"start_conversation")
customRowHeight:UITableViewAutomaticDimension customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
typeof(self) strongSelf = weakSelf; [weakSelf newConversationWithRecipientId:publicKey];
if (!strongSelf) { return; }
NSString *publicKey = strongSelf.searchBar.text;
[strongSelf newConversationWithRecipientId:publicKey];
}]]; }]];
[contents addSection:newConversationSection]; [contents addSection:newConversationSection];
// ======== // ========

@ -1,5 +1,4 @@
#import "ECKeyPair.h" #import "ECKeyPair.h"
#import <SignalCoreKit/OWSAsserts.h>
extern void curve25519_donna(unsigned char *output, const unsigned char *a, const unsigned char *b); extern void curve25519_donna(unsigned char *output, const unsigned char *a, const unsigned char *b);

@ -10,7 +10,7 @@ public extension ECKeyPair {
return "05" + publicKey.map { String(format: "%02hhx", $0) }.joined() return "05" + publicKey.map { String(format: "%02hhx", $0) }.joined()
} }
static func isValidHexEncodedPublicKey(candidate: String) -> Bool { @objc public static func isValidHexEncodedPublicKey(candidate: String) -> Bool {
// Check that it's a valid hexadecimal encoding // Check that it's a valid hexadecimal encoding
let allowedCharacters = CharacterSet(charactersIn: "0123456789ABCDEF") let allowedCharacters = CharacterSet(charactersIn: "0123456789ABCDEF")
guard candidate.uppercased().unicodeScalars.allSatisfy({ allowedCharacters.contains($0) }) else { return false } guard candidate.uppercased().unicodeScalars.allSatisfy({ allowedCharacters.contains($0) }) else { return false }

Loading…
Cancel
Save