Limit allowed characters in display names
This commit is contained in:
parent
669c675035
commit
8f0bd88ed4
|
@ -58,6 +58,9 @@ final class DisplayNameVC : OnboardingBaseViewController {
|
|||
guard !displayName.isEmpty else {
|
||||
return OWSAlerts.showErrorAlert(message: NSLocalizedString("Please pick a display name", comment: ""))
|
||||
}
|
||||
guard displayName.allSatisfy({ "0"..."9" ~= $0 || "a"..."z" ~= $0 || "A"..."Z" ~= $0 || $0 == "_" }) else {
|
||||
return OWSAlerts.showErrorAlert(message: NSLocalizedString("Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters", comment: ""))
|
||||
}
|
||||
guard !OWSProfileManager.shared().isProfileNameTooLong(displayName) else {
|
||||
return OWSAlerts.showErrorAlert(message: NSLocalizedString("Please pick a shorter display name", comment: ""))
|
||||
}
|
||||
|
|
|
@ -398,6 +398,11 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
|
|||
return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a display name", @"")];
|
||||
}
|
||||
|
||||
NSCharacterSet *allowedCharacters = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"];
|
||||
if ([normalizedProfileName rangeOfCharacterFromSet:allowedCharacters.invertedSet].location != NSNotFound) {
|
||||
return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters", @"")];
|
||||
}
|
||||
|
||||
if ([OWSProfileManager.sharedManager isProfileNameTooLong:normalizedProfileName]) {
|
||||
return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a shorter display name", @"")];
|
||||
}
|
||||
|
|
|
@ -2647,3 +2647,4 @@
|
|||
"Enter the URL of the public chat you'd like to join. The Loki Public Chat URL is https://chat.lokinet.org." = "Enter the URL of the public chat you'd like to join. The Loki Public Chat URL is https://chat.lokinet.org.";
|
||||
"Connecting..." = "Connecting...";
|
||||
"Couldn't Connect" = "Couldn't Connect";
|
||||
"Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters" = "Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters";
|
||||
|
|
|
@ -120,7 +120,7 @@ public final class LokiPublicChatMessage : NSObject {
|
|||
let attachmentAnnotations: [JSON] = attachments.map { attachment in
|
||||
let type = attachment.contentType.hasPrefix("image") ? "photo" : "video" // TODO: We should do better than this
|
||||
var attachmentValue: JSON = [
|
||||
// Field required by the .NET API
|
||||
// Fields required by the .NET API
|
||||
"version" : 1, "type" : type,
|
||||
// Custom fields
|
||||
"lokiType" : attachment.kind.rawValue, "server" : attachment.server, "id" : attachment.serverID, "contentType" : attachment.contentType, "size" : attachment.size, "fileName" : attachment.fileName, "flags" : attachment.flags, "width" : attachment.width, "height" : attachment.height, "url" : attachment.url
|
||||
|
|
Loading…
Reference in New Issue