summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-01-14 12:13:46 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-01-28 15:13:45 +0100
commitdb177de20431f2c2dc98d267d586196f67a85915 (patch)
treea01bd610e20eae36da2b81675ae6d4f87aac787c
parent72f4596fb22538ab6691157399c32f151fd98629 (diff)
downloadweechat-db177de20431f2c2dc98d267d586196f67a85915.zip
core: make configuration files, sections and options case sensitive (issue #1872)
-rw-r--r--src/core/wee-command.c4
-rw-r--r--src/core/wee-config-file.c46
-rw-r--r--src/core/wee-config.c6
-rw-r--r--src/gui/gui-color.c2
-rw-r--r--tests/unit/core/test-core-config-file.cpp12
5 files changed, 31 insertions, 39 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 177e296bd..9e37aeb5f 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -6155,7 +6155,7 @@ command_set_display_option_list (const char *message, const char *search,
ptr_option->name);
if ((!search) ||
(search && search[0]
- && (string_match (option_full_name, search, 0))))
+ && (string_match (option_full_name, search, 1))))
{
if (!section_displayed)
{
@@ -6640,7 +6640,7 @@ COMMAND_CALLBACK(unset)
snprintf (option_full_name, length, "%s.%s.%s",
ptr_config->name, ptr_section->name,
ptr_option->name);
- if (string_match (option_full_name, ptr_name, 0))
+ if (string_match (option_full_name, ptr_name, 1))
{
command_unset_option (ptr_option,
option_full_name,
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c
index 0072653e1..e6d30fb5c 100644
--- a/src/core/wee-config-file.c
+++ b/src/core/wee-config-file.c
@@ -103,7 +103,7 @@ config_file_search (const char *name)
for (ptr_config = last_config_file; ptr_config;
ptr_config = ptr_config->prev_config)
{
- rc = string_strcasecmp (ptr_config->name, name);
+ rc = strcmp (ptr_config->name, name);
if (rc == 0)
return ptr_config;
else if (rc < 0)
@@ -130,7 +130,7 @@ config_file_find_pos (const char *name)
for (ptr_config = config_files; ptr_config;
ptr_config = ptr_config->next_config)
{
- if (string_strcasecmp (name, ptr_config->name) < 0)
+ if (strcmp (name, ptr_config->name) < 0)
return ptr_config;
}
@@ -325,7 +325,7 @@ config_file_section_find_pos (struct t_config_file *config_file,
for (ptr_section = config_file->sections; ptr_section;
ptr_section = ptr_section->next_section)
{
- if (string_strcasecmp (name, ptr_section->name) < 0)
+ if (strcmp (name, ptr_section->name) < 0)
return ptr_section;
}
@@ -446,7 +446,7 @@ config_file_search_section (struct t_config_file *config_file,
for (ptr_section = config_file->sections; ptr_section;
ptr_section = ptr_section->next_section)
{
- if (string_strcasecmp (ptr_section->name, name) == 0)
+ if (strcmp (ptr_section->name, name) == 0)
return ptr_section;
}
@@ -556,7 +556,7 @@ config_file_option_find_pos (struct t_config_section *section, const char *name)
for (ptr_option = section->last_option; ptr_option;
ptr_option = ptr_option->prev_option)
{
- if (string_strcasecmp (name, ptr_option->name) >= 0)
+ if (strcmp (name, ptr_option->name) >= 0)
return ptr_option->next_option;
}
@@ -715,7 +715,7 @@ config_file_new_option (struct t_config_file *config_file,
var_type = -1;
for (i = 0; i < CONFIG_NUM_OPTION_TYPES; i++)
{
- if (string_strcasecmp (type, config_option_type_string[i]) == 0)
+ if (string_strcmp (type, config_option_type_string[i]) == 0)
{
var_type = i;
break;
@@ -802,8 +802,8 @@ config_file_new_option (struct t_config_file *config_file,
index_value = 0;
for (i = 0; i < argc; i++)
{
- if (string_strcasecmp (new_option->string_values[i],
- default_value) == 0)
+ if (string_strcmp (new_option->string_values[i],
+ default_value) == 0)
{
index_value = i;
break;
@@ -819,8 +819,8 @@ config_file_new_option (struct t_config_file *config_file,
index_value = 0;
for (i = 0; i < argc; i++)
{
- if (string_strcasecmp (new_option->string_values[i],
- value) == 0)
+ if (string_strcmp (new_option->string_values[i],
+ value) == 0)
{
index_value = i;
break;
@@ -977,7 +977,7 @@ config_file_search_option (struct t_config_file *config_file,
for (ptr_option = section->last_option; ptr_option;
ptr_option = ptr_option->prev_option)
{
- rc = string_strcasecmp (ptr_option->name, option_name);
+ rc = strcmp (ptr_option->name, option_name);
if (rc == 0)
return ptr_option;
else if (rc < 0)
@@ -992,7 +992,7 @@ config_file_search_option (struct t_config_file *config_file,
for (ptr_option = ptr_section->last_option; ptr_option;
ptr_option = ptr_option->prev_option)
{
- rc = string_strcasecmp (ptr_option->name, option_name);
+ rc = strcmp (ptr_option->name, option_name);
if (rc == 0)
return ptr_option;
else if (rc < 0)
@@ -1034,7 +1034,7 @@ config_file_search_section_option (struct t_config_file *config_file,
for (ptr_option = section->last_option; ptr_option;
ptr_option = ptr_option->prev_option)
{
- rc = string_strcasecmp (ptr_option->name, option_name);
+ rc = strcmp (ptr_option->name, option_name);
if (rc == 0)
{
*section_found = section;
@@ -1053,7 +1053,7 @@ config_file_search_section_option (struct t_config_file *config_file,
for (ptr_option = ptr_section->last_option; ptr_option;
ptr_option = ptr_option->prev_option)
{
- rc = string_strcasecmp (ptr_option->name, option_name);
+ rc = strcmp (ptr_option->name, option_name);
if (rc == 0)
{
*section_found = ptr_section;
@@ -1162,13 +1162,13 @@ config_file_string_boolean_is_valid (const char *text)
for (i = 0; config_boolean_true[i]; i++)
{
- if (string_strcasecmp (text, config_boolean_true[i]) == 0)
+ if (string_strcmp (text, config_boolean_true[i]) == 0)
return 1;
}
for (i = 0; config_boolean_false[i]; i++)
{
- if (string_strcasecmp (text, config_boolean_false[i]) == 0)
+ if (string_strcmp (text, config_boolean_false[i]) == 0)
return 1;
}
@@ -1194,7 +1194,7 @@ config_file_string_to_boolean (const char *text)
for (i = 0; config_boolean_true[i]; i++)
{
- if (string_strcasecmp (text, config_boolean_true[i]) == 0)
+ if (string_strcmp (text, config_boolean_true[i]) == 0)
return CONFIG_BOOLEAN_TRUE;
}
@@ -1380,7 +1380,7 @@ config_file_option_set (struct t_config_option *option, const char *value,
option->value = malloc (sizeof (int));
if (option->value)
{
- if (string_strcasecmp (value, "toggle") == 0)
+ if (string_strcmp (value, "toggle") == 0)
{
CONFIG_BOOLEAN(option) = CONFIG_BOOLEAN_TRUE;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
@@ -1403,7 +1403,7 @@ config_file_option_set (struct t_config_option *option, const char *value,
}
else
{
- if (string_strcasecmp (value, "toggle") == 0)
+ if (string_strcmp (value, "toggle") == 0)
{
CONFIG_BOOLEAN(option) =
(CONFIG_BOOLEAN(option) == CONFIG_BOOLEAN_TRUE) ?
@@ -1463,8 +1463,8 @@ config_file_option_set (struct t_config_option *option, const char *value,
{
for (i = 0; option->string_values[i]; i++)
{
- if (string_strcasecmp (option->string_values[i],
- value) == 0)
+ if (string_strcmp (option->string_values[i],
+ value) == 0)
{
value_int = i;
break;
@@ -2944,7 +2944,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload)
}
if (pos[0]
- && string_strcasecmp (pos, WEECHAT_CONFIG_OPTION_NULL) != 0)
+ && string_strcmp (pos, WEECHAT_CONFIG_OPTION_NULL) != 0)
{
undefined_value = 0;
/* remove simple or double quotes and spaces at the end */
@@ -3502,7 +3502,7 @@ config_file_add_option_to_infolist (struct t_infolist *infolist,
goto error;
if (option_name && option_name[0]
- && (!string_match (option_full_name, option_name, 0)))
+ && (!string_match (option_full_name, option_name, 1)))
{
goto end;
}
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 281f7020d..b11755eed 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -2114,7 +2114,7 @@ config_weechat_layout_read_cb (const void *pointer, void *data,
gui_layout_add (ptr_layout);
}
- if (string_strcasecmp (ptr_option_name, "buffer") == 0)
+ if (string_strcmp (ptr_option_name, "buffer") == 0)
{
argv = string_split (value, ";", NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -2133,7 +2133,7 @@ config_weechat_layout_read_cb (const void *pointer, void *data,
string_free_split (argv);
}
}
- else if (string_strcasecmp (ptr_option_name, "window") == 0)
+ else if (string_strcmp (ptr_option_name, "window") == 0)
{
argv = string_split (value, ";", NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
@@ -2171,7 +2171,7 @@ config_weechat_layout_read_cb (const void *pointer, void *data,
string_free_split (argv);
}
}
- else if (string_strcasecmp (ptr_option_name, "current") == 0)
+ else if (string_strcmp (ptr_option_name, "current") == 0)
{
if (config_file_string_to_boolean (value))
gui_layout_current = ptr_layout;
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index 9f90f7734..201171cc1 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -161,7 +161,7 @@ gui_color_search_config (const char *color_name)
for (ptr_option = weechat_config_section_color->options;
ptr_option; ptr_option = ptr_option->next_option)
{
- if (string_strcasecmp (ptr_option->name, color_name) == 0)
+ if (strcmp (ptr_option->name, color_name) == 0)
return gui_color_from_option (ptr_option);
}
diff --git a/tests/unit/core/test-core-config-file.cpp b/tests/unit/core/test-core-config-file.cpp
index dc6ca84b9..96cd67c01 100644
--- a/tests/unit/core/test-core-config-file.cpp
+++ b/tests/unit/core/test-core-config-file.cpp
@@ -82,8 +82,8 @@ TEST(CoreConfigFile, FindPos)
{
POINTERS_EQUAL(NULL, config_file_find_pos (NULL));
POINTERS_EQUAL(config_files, config_file_find_pos (""));
- POINTERS_EQUAL(weechat_config_file->next_config, config_file_find_pos ("weechat"));
- POINTERS_EQUAL(weechat_config_file->next_config, config_file_find_pos ("WEECHAT"));
+ POINTERS_EQUAL(weechat_config_file->next_config, config_file_find_pos ("weechat2"));
+ POINTERS_EQUAL(config_files, config_file_find_pos ("WEECHAT2"));
}
/*
@@ -444,18 +444,14 @@ TEST(CoreConfigFile, StringBooleanIsValid)
LONGS_EQUAL(0, config_file_string_boolean_is_valid ("zzz"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("on"));
- LONGS_EQUAL(1, config_file_string_boolean_is_valid ("ON"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("yes"));
- LONGS_EQUAL(1, config_file_string_boolean_is_valid ("Yes"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("y"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("true"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("t"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("1"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("off"));
- LONGS_EQUAL(1, config_file_string_boolean_is_valid ("OFF"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("no"));
- LONGS_EQUAL(1, config_file_string_boolean_is_valid ("No"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("n"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("false"));
LONGS_EQUAL(1, config_file_string_boolean_is_valid ("f"));
@@ -474,18 +470,14 @@ TEST(CoreConfigFile, StringToBoolean)
LONGS_EQUAL(0, config_file_string_to_boolean ("zzz"));
LONGS_EQUAL(1, config_file_string_to_boolean ("on"));
- LONGS_EQUAL(1, config_file_string_to_boolean ("ON"));
LONGS_EQUAL(1, config_file_string_to_boolean ("yes"));
- LONGS_EQUAL(1, config_file_string_to_boolean ("Yes"));
LONGS_EQUAL(1, config_file_string_to_boolean ("y"));
LONGS_EQUAL(1, config_file_string_to_boolean ("true"));
LONGS_EQUAL(1, config_file_string_to_boolean ("t"));
LONGS_EQUAL(1, config_file_string_to_boolean ("1"));
LONGS_EQUAL(0, config_file_string_to_boolean ("off"));
- LONGS_EQUAL(0, config_file_string_to_boolean ("OFF"));
LONGS_EQUAL(0, config_file_string_to_boolean ("no"));
- LONGS_EQUAL(0, config_file_string_to_boolean ("No"));
LONGS_EQUAL(0, config_file_string_to_boolean ("n"));
LONGS_EQUAL(0, config_file_string_to_boolean ("false"));
LONGS_EQUAL(0, config_file_string_to_boolean ("f"));