From 35a0711713b2dd69457ce862009f2959afe26eea Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 20 Jan 2021 01:28:55 +0100 Subject: [PATCH] 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 --- src/yunohost/app.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 0349f92e7..ade39bf20 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -1892,6 +1892,18 @@ def _get_app_settings(app_id): # 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... 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']: return settings except (IOError, TypeError, KeyError): @@ -2423,7 +2435,7 @@ class YunoHostArgumentFormatParser(object): if parsed_question.ask is None: parsed_question.ask = "Enter value for '%s':" % parsed_question.name - + # Empty value is parsed as empty string if parsed_question.default == "": parsed_question.default = None