From 255e02b7daaaf0e7f01ac7cd16e1c75fb0301773 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Thu, 27 Jul 2017 19:00:40 +0200 Subject: [PATCH] context: Do not allow show, list or none as new context names - Thanks to silviof. --- src/commands/CmdContext.cpp | 6 ++++++ src/l10n/deu-DEU.h | 1 + src/l10n/eng-USA.h | 1 + src/l10n/epo-RUS.h | 1 + src/l10n/esp-ESP.h | 1 + src/l10n/fra-FRA.h | 1 + src/l10n/ita-ITA.h | 1 + src/l10n/jpn-JPN.h | 1 + src/l10n/pol-POL.h | 1 + src/l10n/por-PRT.h | 1 + src/libshared | 2 +- 11 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/commands/CmdContext.cpp b/src/commands/CmdContext.cpp index ca0e25e35..4ee5cf3ee 100644 --- a/src/commands/CmdContext.cpp +++ b/src/commands/CmdContext.cpp @@ -137,6 +137,12 @@ void CmdContext::defineContext (const std::vector & words, std::str auto name = "context." + words[1]; auto value = joinWords (words, 2); + // Make sure nobody creates a context with name 'list', 'none' or 'show' + if (words[1] == "none" or words[1] == "list" or words[1] == "show") + { + throw format (STRING_CMD_CONTEXT_DEF_INVLD, words[1]); + } + // Check if the value is a proper filter by filtering current pending.data Filter filter; std::vector filtered; diff --git a/src/l10n/deu-DEU.h b/src/l10n/deu-DEU.h index 052676906..8bc42eaab 100644 --- a/src/l10n/deu-DEU.h +++ b/src/l10n/deu-DEU.h @@ -528,6 +528,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/l10n/eng-USA.h b/src/l10n/eng-USA.h index eb7865ef3..6bed1c2e3 100644 --- a/src/l10n/eng-USA.h +++ b/src/l10n/eng-USA.h @@ -526,6 +526,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definition aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/l10n/epo-RUS.h b/src/l10n/epo-RUS.h index 663324ef2..1773cf7d0 100644 --- a/src/l10n/epo-RUS.h +++ b/src/l10n/epo-RUS.h @@ -528,6 +528,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/l10n/esp-ESP.h b/src/l10n/esp-ESP.h index 2bb5e16b9..658c29486 100644 --- a/src/l10n/esp-ESP.h +++ b/src/l10n/esp-ESP.h @@ -540,6 +540,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Definición de contexto abortada." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Validación de filtro fallida: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "El filtro '{1}' coincide con 0 tareas pendientes. ¿Quiere continuar?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Contexto '{1}' eliminado." #define STRING_CMD_CONTEXT_DEL_FAIL "Contexto '{1}' no eliminado." #define STRING_CMD_CONTEXT_DEL_USAG "El nombre del contexto necesita ser especificado." diff --git a/src/l10n/fra-FRA.h b/src/l10n/fra-FRA.h index 11b7ef60b..578108aa1 100644 --- a/src/l10n/fra-FRA.h +++ b/src/l10n/fra-FRA.h @@ -530,6 +530,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/l10n/ita-ITA.h b/src/l10n/ita-ITA.h index bb0c72310..04c6df316 100644 --- a/src/l10n/ita-ITA.h +++ b/src/l10n/ita-ITA.h @@ -529,6 +529,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/l10n/jpn-JPN.h b/src/l10n/jpn-JPN.h index 7789b8de8..9be5faca3 100644 --- a/src/l10n/jpn-JPN.h +++ b/src/l10n/jpn-JPN.h @@ -530,6 +530,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/l10n/pol-POL.h b/src/l10n/pol-POL.h index 3016a4700..a002621c6 100644 --- a/src/l10n/pol-POL.h +++ b/src/l10n/pol-POL.h @@ -530,6 +530,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/l10n/por-PRT.h b/src/l10n/por-PRT.h index b4774f03e..60fabdfc7 100644 --- a/src/l10n/por-PRT.h +++ b/src/l10n/por-PRT.h @@ -530,6 +530,7 @@ #define STRING_CMD_CONTEXT_DEF_ABRT "Context definiton aborted." #define STRING_CMD_CONTEXT_DEF_ABRT2 "Filter validation failed: {1}" #define STRING_CMD_CONTEXT_DEF_CONF "The filter '{1}' matches 0 pending tasks. Do you wish to continue?" +#define STRING_CMD_CONTEXT_DEF_INVLD "The name '{1}' is reserved and not allowed to use as a context name." #define STRING_CMD_CONTEXT_DEL_SUCC "Context '{1}' deleted." #define STRING_CMD_CONTEXT_DEL_FAIL "Context '{1}' not deleted." #define STRING_CMD_CONTEXT_DEL_USAG "Context name needs to be specified." diff --git a/src/libshared b/src/libshared index f1a3cd6bf..198dcd368 160000 --- a/src/libshared +++ b/src/libshared @@ -1 +1 @@ -Subproject commit f1a3cd6bfabfb083fe3c26f580a15c0d60a92ee9 +Subproject commit 198dcd368501076fe31b22d828ae72066d0e6291