From 435b5b7ff97c7e52d50c002c9480af7066ead2ad Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 25 Mar 2018 16:35:33 +1100 Subject: 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 --- src/remote.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/remote.cc') 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); -- cgit v1.2.3