Additional users path

main
Bob Mottram 2021-06-03 19:30:48 +01:00
parent efe1b54b38
commit ca17ba9fe3
2 changed files with 25 additions and 5 deletions

View File

@ -1216,15 +1216,16 @@ def getActorJson(handle: str, http: bool, gnunet: bool,
handle.startswith('http') or \
handle.startswith('dat'):
# format: https://domain/@nick
prefixes = getProtocolPrefixes()
for prefix in prefixes:
handle = handle.replace(prefix, '')
handle = handle.replace('/@', '/users/')
if not hasUsersPath(handle):
originalHandle = handle
if not hasUsersPath(originalHandle):
if not quiet or debug:
print('getActorJson: Expected actor format: ' +
'https://domain/@nick or https://domain/users/nick')
return None
prefixes = getProtocolPrefixes()
for prefix in prefixes:
handle = handle.replace(prefix, '')
handle = handle.replace('/@', '/users/')
if '/users/' in handle:
nickname = handle.split('/users/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
@ -1245,6 +1246,15 @@ def getActorJson(handle: str, http: bool, gnunet: bool,
nickname = handle.split('/u/')[1]
nickname = nickname.replace('\n', '').replace('\r', '')
domain = handle.split('/u/')[0]
elif '://' in originalHandle:
domain = originalHandle.split('://')[1]
if '/' in domain:
domain = domain.split('/')[0]
if '://' + domain + '/' not in originalHandle:
return None
nickname = originalHandle.split('://' + domain + '/')[1]
if '/' in nickname or '.' in nickname:
return None
else:
# format: @nick@domain
if '@' not in handle:

View File

@ -97,6 +97,16 @@ def hasUsersPath(pathStr: str) -> bool:
for usersStr in usersList:
if '/' + usersStr + '/' in pathStr:
return True
if '://' in pathStr:
domain = pathStr.split('://')[1]
if '/' in domain:
domain = domain.split('/')[0]
if '://' + domain + '/' not in pathStr:
return False
nickname = pathStr.split('://' + domain + '/')[1]
if '/' in nickname or '.' in nickname:
return False
return True
return False