mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Improve check url validity for permissions
This commit is contained in:
parent
d95341840b
commit
2a0866b583
2 changed files with 8 additions and 6 deletions
|
@ -428,7 +428,7 @@ def _check_and_normalize_permission_path(url):
|
||||||
return url
|
return url
|
||||||
|
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
return "/" + url.strip("/")
|
return url.rstrip("/")
|
||||||
|
|
||||||
# Uri with domain
|
# Uri with domain
|
||||||
domains = domain_list()['domains']
|
domains = domain_list()['domains']
|
||||||
|
@ -455,7 +455,7 @@ def _check_and_normalize_permission_path(url):
|
||||||
raise YunohostError('domain_unknown')
|
raise YunohostError('domain_unknown')
|
||||||
|
|
||||||
if '/' in url:
|
if '/' in url:
|
||||||
path = '/' + url.split('/', 1)[1].strip('/')
|
path = url.split('/', 1)[1].rstrip('/')
|
||||||
return domain + path
|
return domain + path
|
||||||
else:
|
else:
|
||||||
return domain
|
return domain
|
||||||
|
|
|
@ -62,11 +62,13 @@ def user_permission_list(short=False, full=False, ignore_system_perms=False, ful
|
||||||
# Parse / organize information to be outputed
|
# Parse / organize information to be outputed
|
||||||
app_settings = {app['id']: app_setting(app['id'], 'domain') + app_setting(app['id'], 'path') for app in app_list()['apps']}
|
app_settings = {app['id']: app_setting(app['id'], 'domain') + app_setting(app['id'], 'path') for app in app_list()['apps']}
|
||||||
|
|
||||||
def complete_url(url, name):
|
def _complete_url(url, name):
|
||||||
if url is None:
|
if url is None:
|
||||||
return None
|
return None
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
return app_settings[name.split('.')[0]] + url
|
return app_settings[name.split('.')[0]] + url.rstrip("/")
|
||||||
|
if url.startswith('re:/'):
|
||||||
|
return 're:' + app_settings[name.split('.')[0]] + url.lstrip('re:/')
|
||||||
else:
|
else:
|
||||||
return url
|
return url
|
||||||
|
|
||||||
|
@ -88,8 +90,8 @@ def user_permission_list(short=False, full=False, ignore_system_perms=False, ful
|
||||||
permissions[name]["show_tile"] = False if infos.get("showTile", [False])[0] == "FALSE" else True
|
permissions[name]["show_tile"] = False if infos.get("showTile", [False])[0] == "FALSE" else True
|
||||||
permissions[name]["protected"] = False if infos.get("isProtected", [False])[0] == "FALSE" else True
|
permissions[name]["protected"] = False if infos.get("isProtected", [False])[0] == "FALSE" else True
|
||||||
if full_path and name.split(".")[0] not in SYSTEM_PERMS:
|
if full_path and name.split(".")[0] not in SYSTEM_PERMS:
|
||||||
permissions[name]["url"] = complete_url(infos.get("URL", [None])[0], name)
|
permissions[name]["url"] = _complete_url(infos.get("URL", [None])[0], name)
|
||||||
permissions[name]["additional_urls"] = [complete_url(url, name) for url in infos.get("additionalUrls", [None])]
|
permissions[name]["additional_urls"] = [_complete_url(url, name) for url in infos.get("additionalUrls", [None])]
|
||||||
else:
|
else:
|
||||||
permissions[name]["url"] = infos.get("URL", [None])[0]
|
permissions[name]["url"] = infos.get("URL", [None])[0]
|
||||||
permissions[name]["additional_urls"] = infos.get("additionalUrls", [None])
|
permissions[name]["additional_urls"] = infos.get("additionalUrls", [None])
|
||||||
|
|
Loading…
Add table
Reference in a new issue