fix(@dekstop/chat): creating a chat with numeric only crashes the app

Fixes #4860
This commit is contained in:
Sale Djenic 2022-02-23 15:27:44 +01:00 committed by Iuri Matias
parent d11a49f26f
commit 91e42aba6d
2 changed files with 12 additions and 2 deletions

View File

@ -8,8 +8,6 @@ include ../../../app/core/tasks/common
# Async lookup ENS contact # Async lookup ENS contact
################################################# #################################################
const PK_LENGTH_0X_INCLUDED = 132
type type
LookupContactTaskArg = ref object of QObjectTaskArg LookupContactTaskArg = ref object of QObjectTaskArg
value: string value: string

View File

@ -16,6 +16,8 @@ import ../../../backend/utils as status_utils
export contacts_dto, status_update_dto, contact_details export contacts_dto, status_update_dto, contact_details
const PK_LENGTH_0X_INCLUDED = 132
include async_tasks include async_tasks
logScope: logScope:
@ -211,6 +213,16 @@ QtObject:
result = self.fetchContact(id) result = self.fetchContact(id)
if result.id.len == 0: if result.id.len == 0:
if(not id.startsWith("0x")):
debug "id is not in a hex format"
return
var num64: int64
let parsedChars = parseHex(id, num64)
if(parsedChars != PK_LENGTH_0X_INCLUDED):
debug "id doesn't have expected lenght"
return
let alias = self.generateAlias(id) let alias = self.generateAlias(id)
let identicon = self.generateIdenticonURL(id) let identicon = self.generateIdenticonURL(id)
result = ContactsDto( result = ContactsDto(