summaryrefslogtreecommitdiff
path: root/src/remote.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-03-25 16:35:33 +1100
committerMaxime Coste <mawww@kakoune.org>2018-03-25 16:35:33 +1100
commit435b5b7ff97c7e52d50c002c9480af7066ead2ad (patch)
tree0e5e9bbf0443e8078a56fde1b9cd620309f048f7 /src/remote.cc
parent2d85e945167bb47fac5389172f190536352df8f1 (diff)
Unify code that validates identifiers in Kakoune
Session/Client/User modes names are now requiered to be "identifiers" they must be in [a-zA-Z0-9_-]. Option names are the same except they do not allow '-' as they need to be made available through the env vars and '-' is not supported there. Fixes #1946
Diffstat (limited to 'src/remote.cc')
-rw-r--r--src/remote.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/remote.cc b/src/remote.cc
index 521663f6..f3dd7d06 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -777,8 +777,8 @@ private:
Server::Server(String session_name)
: m_session{std::move(session_name)}
{
- if (contains(m_session, '/'))
- throw runtime_error{"Cannot create sessions with '/' in their name"};
+ if (not all_of(m_session, is_identifier))
+ throw runtime_error{format("Invalid session name '{}'", session_name)};
int listen_sock = socket(AF_UNIX, SOCK_STREAM, 0);
fcntl(listen_sock, F_SETFD, FD_CLOEXEC);
@@ -816,8 +816,8 @@ Server::Server(String session_name)
bool Server::rename_session(StringView name)
{
- if (contains(name, '/'))
- throw runtime_error{"Cannot create sessions with '/' in their name"};
+ if (not all_of(name, is_identifier))
+ throw runtime_error{format("Invalid session name '{}'", name)};
String old_socket_file = format("{}/kakoune/{}/{}", tmpdir(),
get_user_name(geteuid()), m_session);