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

Support almost arbitrary characters in dir names #101

Merged
merged 1 commit into from
May 19, 2024
Merged

Support almost arbitrary characters in dir names #101

merged 1 commit into from
May 19, 2024

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented May 19, 2024

dconf itself places minimal restrictions on key paths. dconf_is_key and dconf_is_dir just stipulate the following:

  • Path must start with /.
  • Path must not contain //.
  • Key paths must not end with /.
  • Directory paths must end with /.

So in theory, they can all contain special characters like []*#@. In practice, dconf dump will fail to print paths containing [ or ] due to limitations of GKeyFile enforced by g_key_file_is_group_name so those or control characters will not really appear in input of dconf2nix. But it can still contain all other kinds of characters including spaces at the start or end.

Since the spaces are now preserved as expected, we need to remove them from the test cases (not sure how they got there). Also clean up the duplicate dirs/groups.

Keys have slightly tighter restrictions introduced by g_key_file_is_key_name. Whitespace is only allowed in the middle of a key and = is not allowed at all. [ and ] are not allowed either, except at the end in a subkey suffix, which has further restrictions. But I doubt anyone will want special characters in keys so I am only extending it with an underscore.

dconf itself places minimal restrictions on key paths.
`dconf_is_key` and `dconf_is_dir` just stipulate the following:

- Path must start with `/`.
- Path must not contain `//`.
- Key paths must not end with `/`.
- Directory paths must end with `/`.

So in theory, they can all contain special characters like `[]*#@`.
In practice, `dconf dump` will fail to print paths containing `[` or `]`
due to limitations of `GKeyFile` enforced by `g_key_file_is_group_name`
so those or control characters will not really appear in input of dconf2nix.
But it can still contain all other kinds of characters including spaces
at the start or end.

Since the spaces are now preserved as expected, we need to remove them
from the test cases (not sure how they got there). Also clean up the
duplicate dirs/groups.

Keys have slightly tighter restrictions introduced by `g_key_file_is_key_name`.
Whitespace is only allowed in the middle of a key and `=` is not allowed at all.
`[` and `]` are not allowed either, except at the end in a subkey suffix,
which has further restrictions. But I doubt anyone will want special
characters in keys so I am only extending it with an underscore.
@jtojnar jtojnar merged commit 2f35ffa into master May 19, 2024
1 check passed
@jtojnar jtojnar deleted the keyfile branch May 19, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant