Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config panel can't handle properly hashtags in strings #2501

Open
oleole39 opened this issue Dec 16, 2024 · 0 comments
Open

Config panel can't handle properly hashtags in strings #2501

oleole39 opened this issue Dec 16, 2024 · 0 comments
Labels
👾 bug Something isn't working

Comments

@oleole39
Copy link

oleole39 commented Dec 16, 2024

Describe the bug

Config panel's ecosystem does not handle correctly the number sign (#), most likely due to the fact it is considered as the comment sign within transitional YAML output (good guess from @alexAubin).

1. Custom getters

When a custom getter (defined in app package's config script) returns a string containing a hashtag, the YAML configuration generated using this helper discards everything from the # sign.

Typically, fontcompare_ynh has a config panel containing 2 color pickers. Color pickers' values are HTML color codes (e.g: #cccccc). If we pick a different color than default and click save in the Webadmin, the config panel still shows default color.
Running yunohost app config get fontcompare --full --debug shows in particular background_color: None (would the string be test#AB, YAML config would only take into account test...)

The issue originates in read_yaml as defined in Moulinette's filesystem.py, which is called in app.py via hook.py.

To solve this, we need the values to be between quotes when passed in read_yaml
It can be fixed either:

2. Others ?

I wonder whether this issue can impact other parts of the code as well. I noticed for instance that in element_ynh's config panel, when changing the "Brand text" input box from default Element to:

  • Elementab, then after save Elementab is displayed

    Elementab save related log
    2024-12-16 01:05:45,373: DEBUG - + for short_setting in "${!old[@]}"
    2024-12-16 01:05:45,373: DEBUG - + ynh_app_config_apply_one brand_text
    2024-12-16 01:05:45,373: DEBUG - + _ynh_app_config_apply_one brand_text
    2024-12-16 01:05:45,373: DEBUG - + local short_setting=brand_text
    2024-12-16 01:05:45,373: DEBUG - + local setter=set__brand_text
    2024-12-16 01:05:45,373: DEBUG - + local bind=settings
    2024-12-16 01:05:45,373: DEBUG - + local type=string
    2024-12-16 01:05:45,374: DEBUG - + '[' true == true ']'
    2024-12-16 01:05:45,374: INFO - [###############+++++] > Applying the new configuration...
    2024-12-16 01:05:45,378: DEBUG - + grep -q '^function$'
    2024-12-16 01:05:45,378: DEBUG - + type -t set__brand_text
    2024-12-16 01:05:45,379: DEBUG - + [[ settings == *\(* ]]
    2024-12-16 01:05:45,379: DEBUG - + [[ settings == \n\u\l\l ]]
    2024-12-16 01:05:45,379: DEBUG - + [[ string == \f\i\l\e ]]
    2024-12-16 01:05:45,379: DEBUG - + [[ settings == \s\e\t\t\i\n\g\s ]]
    2024-12-16 01:05:45,379: DEBUG - + ynh_app_setting_set --key=brand_text --value=Elementab
    2024-12-16 01:05:45,379: DEBUG - + local _globalapp=element
    2024-12-16 01:05:45,379: DEBUG - + args_array=(['a']='app=' ['k']='key=' ['v']='value=')
    2024-12-16 01:05:45,380: DEBUG - + local -A args_array
    2024-12-16 01:05:45,380: DEBUG - + local app
    2024-12-16 01:05:45,380: DEBUG - + local key
    2024-12-16 01:05:45,380: DEBUG - + local value
    2024-12-16 01:05:45,380: DEBUG - + ynh_handle_getopts_args --key=brand_text --value=Elementab
    2024-12-16 01:05:45,380: DEBUG - ++ grep xtrace
    2024-12-16 01:05:45,380: DEBUG - ++ set +o
    2024-12-16 01:05:45,380: DEBUG - + local 'xtrace_enable=set -o xtrace'
    2024-12-16 01:05:45,381: DEBUG - + set +o xtrace
    2024-12-16 01:05:45,457: DEBUG - + app=element
    2024-12-16 01:05:45,457: DEBUG - + ynh_app_setting set element brand_text Elementab
    2024-12-16 01:05:45,459: DEBUG - ++ set +o
    2024-12-16 01:05:45,459: DEBUG - ++ grep xtrace
    2024-12-16 01:05:45,463: DEBUG - + local 'xtrace_enable=set -o xtrace'
    2024-12-16 01:05:45,464: DEBUG - + set +o xtrace
    2024-12-16 01:05:45,577: DEBUG - + ynh_print_info 'Configuration key '\''brand_text'\'' edited in app settings'
    2024-12-16 01:05:45,577: DEBUG - + echo 'Configuration key '\''brand_text'\'' edited in app settings'
    2024-12-16 01:05:45,577: INFO - Configuration key 'brand_text' edited in app settings
    
  • Elementab#hello, then after save only Elementab is displayed

    Element#ab save related log
    2024-12-16 01:05:59,579: DEBUG - + for short_setting in "${!old[@]}"
    2024-12-16 01:05:59,579: DEBUG - + ynh_app_config_apply_one brand_text
    2024-12-16 01:05:59,579: DEBUG - + _ynh_app_config_apply_one brand_text
    2024-12-16 01:05:59,579: DEBUG - + local short_setting=brand_text
    2024-12-16 01:05:59,579: DEBUG - + local setter=set__brand_text
    2024-12-16 01:05:59,580: DEBUG - + local bind=settings
    2024-12-16 01:05:59,580: DEBUG - + local type=string
    2024-12-16 01:05:59,580: DEBUG - + '[' true == true ']'
    2024-12-16 01:05:59,580: DEBUG - + type -t set__brand_text
    2024-12-16 01:05:59,580: DEBUG - + grep -q '^function$'
    2024-12-16 01:05:59,580: DEBUG - + [[ settings == *\(* ]]
    2024-12-16 01:05:59,581: DEBUG - + [[ settings == \n\u\l\l ]]
    2024-12-16 01:05:59,581: DEBUG - + [[ string == \f\i\l\e ]]
    2024-12-16 01:05:59,581: DEBUG - + [[ settings == \s\e\t\t\i\n\g\s ]]
    2024-12-16 01:05:59,581: DEBUG - + ynh_app_setting_set --key=brand_text --value=Elementab#hello
    2024-12-16 01:05:59,581: DEBUG - + local _globalapp=element
    2024-12-16 01:05:59,581: DEBUG - + args_array=(['a']='app=' ['k']='key=' ['v']='value=')
    2024-12-16 01:05:59,581: DEBUG - + local -A args_array
    2024-12-16 01:05:59,582: DEBUG - + local app
    2024-12-16 01:05:59,582: DEBUG - + local key
    2024-12-16 01:05:59,582: DEBUG - + local value
    2024-12-16 01:05:59,582: DEBUG - + ynh_handle_getopts_args --key=brand_text --value=Elementab#hello
    2024-12-16 01:05:59,581: DEBUG - + local _globalapp=element
    2024-12-16 01:05:59,582: DEBUG - ++ grep xtrace
    2024-12-16 01:05:59,583: DEBUG - ++ set +o
    2024-12-16 01:05:59,583: DEBUG - + local 'xtrace_enable=set -o xtrace'
    2024-12-16 01:05:59,583: DEBUG - + set +o xtrace
    2024-12-16 01:05:59,657: DEBUG - + app=element
    2024-12-16 01:05:59,658: DEBUG - + ynh_app_setting set element brand_text Elementab#hello
    2024-12-16 01:05:59,581: DEBUG - + local _globalapp=element
    2024-12-16 01:05:59,659: DEBUG - ++ set +o
    2024-12-16 01:05:59,660: DEBUG - ++ grep xtrace
    2024-12-16 01:05:59,663: DEBUG - + local 'xtrace_enable=set -o xtrace'
    2024-12-16 01:05:59,664: DEBUG - + set +o xtrace
    2024-12-16 01:05:59,770: DEBUG - + ynh_print_info 'Configuration key '\''brand_text'\'' edited in app settings'
    2024-12-16 01:05:59,770: DEBUG - + echo 'Configuration key '\''brand_text'\'' edited in app settings'
    2024-12-16 01:05:59,770: INFO - Configuration key 'brand_text' edited in app settings
    

It shows there might be a similar issue with ynh_app_setting set

Context

  • Hardware: VPS bought online
  • YunoHost version: 12.0.8.2
  • I have access to my server: Through SSH | through the webadmin
  • Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👾 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant