diff options
author | Ghjuvan Lacambre <code@lacamb.re> | 2023-05-28 16:04:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-28 16:04:54 +0200 |
commit | 5a3752889c5b7e18d1041eb873ca2fa9ceb814bd (patch) | |
tree | 07e0a62ee0abe2814d310565b5d71b3a613de85f /src/nvim/os/stdpaths.c | |
parent | d561830a5242a00545a320acb80be083dd590d05 (diff) | |
download | rneovim-5a3752889c5b7e18d1041eb873ca2fa9ceb814bd.tar.gz rneovim-5a3752889c5b7e18d1041eb873ca2fa9ceb814bd.tar.bz2 rneovim-5a3752889c5b7e18d1041eb873ca2fa9ceb814bd.zip |
fix(NVIM_APPNAME): show error message if $NVIM_APPNAME is invalid
Closes https://github.com/neovim/neovim/issues/23056.
Diffstat (limited to 'src/nvim/os/stdpaths.c')
-rw-r--r-- | src/nvim/os/stdpaths.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 8b62b9e895..53ddda22fa 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -69,6 +69,19 @@ const char *get_appname(void) return env_val; } +/// Ensure that APPNAME is valid. In particular, it cannot contain directory separators. +bool appname_is_valid(void) +{ + const char *appname = get_appname(); + const size_t appname_len = strlen(appname); + for (size_t i = 0; i < appname_len; i++) { + if (appname[i] == PATHSEP) { + return false; + } + } + return true; +} + /// Return XDG variable value /// /// @param[in] idx XDG variable to use. |