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

Improper handling of bracket-enclosed strings in configuration panel string form. #2302

Open
ashledombos opened this issue Dec 28, 2023 · 2 comments
Labels
📦 App packaging 👾 bug Something isn't working

Comments

@ashledombos
Copy link

Describe the Bug

YunoHost seems to misinterpret strings enclosed in brackets as arrays or lists when retrieving configuration settings (_ynh_app_config_get_one function). Specifically, when a config value like [prefix] is read from a configuration file (in my case it’s a simple file containing the prefix string), it's incorrectly formatted as [ "prefix"], suggesting an erroneous interpretation as a list or array instead of a simple string. I am currently working on a mailing list package, which includes a configuration panel option to modify the subject prefix. The use of brackets to encapsulate prefixes is a common convention, following standard mailing lists practice. For example, a typical mailing list subject might start with [ListName] to clearly indicate the source or category of the email.

Context

  • Hardware: KVM, virtual box etc.
  • YunoHost version: 11.2.8.2
  • Access to server: Through SSH and Webadmin
  • Special context or tweaks: No special context or tweaks applied

To Reproduce

Reproducing the issue involves either creating a YunoHost package with a string field in config_panel.toml and retrieving a text of the type [mytext] via a bind or a getter, or by directly invoking the relevant functions. The two methods are as follows:

  1. Through Package Creation with config_panel.toml:

    • Create a YunoHost package or modify an existing one.
    • Use or add a string field in the config_panel.toml file.
    • Set up the package to retrieve a value like [mytext] either through a bind mechanism or a custom getter function. For instance in my case :
    • Observe how the system handles this string when it's read from the configuration.
  2. By Directly Invoking Functions:

Expected Behavior

The expected behavior is for YunoHost to correctly interpret and display simple strings, even when they are enclosed in brackets. For example, a string [prefix] in the config file should be read and displayed as [prefix], not [ "prefix"].

Approaches for Solution

I have two potential solutions in mind :

  1. Modifying Existing Scripts:

    • Adjust the _ynh_app_config_get_one and ynh_read_var_in_file functions to better handle simple strings, especially those enclosed in brackets. This might involve adding conditions to check if a string matches a simple pattern and then extracting it directly without using complex regular expressions.
  2. Adding a Descripteur in config_panel.toml:

    • Implement a new descriptor (e.g., file=text) in config_panel.toml. This descriptor would inform _ynh_app_config_get_one about the type of content (simple text or complex structure), which would then pass this information to ynh_read_var_in_file to adjust the extraction logic accordingly.

Logs

Logs were not applicable at the moment of reporting. The issue is more about the potential improvement in the script logic than a specific error in the system.

@ashledombos ashledombos added the 👾 bug Something isn't working label Dec 28, 2023
@alexAubin
Copy link
Member

I am currently working on a mailing list package, which includes a configuration panel option to modify the subject prefix.

It would help to understand the issue and reproduce it if you can simply share the name of the app and the relevant conf part ...

@ashledombos
Copy link
Author

Hi @alexAubin
Here is the relevant conf part get_prefix

https://github.com/YunoHost-Apps/mlmmj_ynh/blob/e66126f7146cb229cab4fc4c03c6f59dcc455c94/scripts/config#L43

by default it will take the name of the ml (which you choose at install) between two brackets []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 App packaging 👾 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants