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/option_manager.hh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/option_manager.hh') diff --git a/src/option_manager.hh b/src/option_manager.hh index 674cf6da..84c1be98 100644 --- a/src/option_manager.hh +++ b/src/option_manager.hh @@ -214,13 +214,11 @@ public: const T& value, OptionFlags flags = OptionFlags::None) { - auto is_not_identifier = [](char c) { - return (c < 'a' or c > 'z') and - (c < 'A' or c > 'Z') and - (c < '0' or c > '9') and c != '_'; + auto is_option_identifier = [](char c) { + return is_basic_alpha(c) or is_basic_digit(c) or c == '_'; }; - if (contains_that(name, is_not_identifier)) + if (not all_of(name, is_option_identifier)) throw runtime_error{format("name '{}' contains char out of [a-zA-Z0-9_]", name)}; auto& opts = m_global_manager.m_options; -- cgit v1.2.3