Stupid yolopatch for not-normalized app path settings >_> (#1141)

* Update app.py
* Be more careful (c.f. _normalize_domain_path code ... maybe the path doesn't start with / either ..)
* Annnnnd ignore case where path is '/' which is fine
This commit is contained in:
Alexandre Aubin 2021-01-20 01:28:55 +01:00 committed by GitHub
parent b7293f33b9
commit 35a0711713
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1892,6 +1892,18 @@ def _get_app_settings(app_id):
# If label contains unicode char, this may later trigger issues when building strings... # If label contains unicode char, this may later trigger issues when building strings...
# FIXME: this should be propagated to read_yaml so that this fix applies everywhere I think... # FIXME: this should be propagated to read_yaml so that this fix applies everywhere I think...
settings = {k: _encode_string(v) for k, v in settings.items()} settings = {k: _encode_string(v) for k, v in settings.items()}
# Stupid fix for legacy bullshit
# In the past, some setups did not have proper normalization for app domain/path
# Meaning some setups (as of January 2021) still have path=/foobar/ (with a trailing slash)
# resulting in stupid issue unless apps using ynh_app_normalize_path_stuff
# So we yolofix the settings if such an issue is found >_>
# A simple call to `yunohost app list` (which happens quite often) should be enough
# to migrate all app settings ... so this can probably be removed once we're past Bullseye...
if settings.get("path") != "/" and (settings.get("path", "").endswith("/") or not settings.get("path", "/").startswith("/")):
settings["path"] = "/" + settings["path"].strip("/")
_set_app_settings(app_id, settings)
if app_id == settings['id']: if app_id == settings['id']:
return settings return settings
except (IOError, TypeError, KeyError): except (IOError, TypeError, KeyError):