Catch invalid network names in IdentityFromString/LinkAccounts

This commit is contained in:
moneromooo 2015-02-07 10:01:13 +00:00
parent 3e88744e3b
commit db727c9329
2 changed files with 8 additions and 1 deletions

View File

@ -163,7 +163,11 @@ def LinkAccount(link,cmd):
if linked_identity == None:
link.send('usage: !link_account [<network>:]<username>')
return
linked_identity=IdentityFromString(link,linked_identity)
try:
linked_identity=IdentityFromString(link,linked_identity)
except Exception,e:
link.send('%s is invalid' % linked_identity)
return
ok,reason=LinkCore(link,linked_identity)
if not ok:
link.send('An error occured')

View File

@ -381,6 +381,9 @@ def IdentityFromString(link,s):
parts=s.split(':')
network_name=parts[0]
network=GetNetworkByName(network_name)
if not network:
log_error('unknown network: %s' % network_name)
raise RuntimeError('Unknown network: %s' % network_name)
nick=parts[1]
return network.name+':'+network.canonicalize(nick)