From bc1aa0bc0f6661f9950f2302ef6c2dfb9dfa76a5 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 22 Aug 2015 12:34:10 -0400 Subject: [PATCH] TW-1666: import should reject invalid data - Thanks to Daniel Shahaf. --- ChangeLog | 1 + src/Task.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 + 11 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7174d02f1..9e8bcd1f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -125,6 +125,7 @@ David Patrick). - TW-1655 Inform "No changes made." when quitting early due to signal (thanks to Daniel Shahaf). +- TW-1666 import should reject invalid data (thanks to Daniel Shahaf). - Prevent potential task duplication during import for non-pending tasks. - Show the active context in "context list", if any is active. - Fix "task edit" dropping annotation text after newlines. diff --git a/src/Task.cpp b/src/Task.cpp index f9b7eafbc..90239906b 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -178,7 +178,7 @@ Task::status Task::textToStatus (const std::string& input) else if (input[0] == 'r') return Task::recurring; else if (input[0] == 'w') return Task::waiting; - return Task::pending; + throw format (STRING_ERROR_BAD_STATUS, input); } //////////////////////////////////////////////////////////////////////////////// @@ -1401,7 +1401,9 @@ void Task::substitute ( // void Task::validate (bool applyDefault /* = true */) { - Task::status status = getStatus (); + Task::status status = Task::pending; + if (get ("status") != "") + status = getStatus (); // 1) Provide missing attributes where possible // Provide a UUID if necessary. Validate if present. diff --git a/src/l10n/deu-DEU.h b/src/l10n/deu-DEU.h index 29869edbf..d6eb5c766 100644 --- a/src/l10n/deu-DEU.h +++ b/src/l10n/deu-DEU.h @@ -753,6 +753,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "Keine Aufgaben." diff --git a/src/l10n/eng-USA.h b/src/l10n/eng-USA.h index ac6176e4f..43c3225e9 100644 --- a/src/l10n/eng-USA.h +++ b/src/l10n/eng-USA.h @@ -751,6 +751,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "No tasks." diff --git a/src/l10n/epo-RUS.h b/src/l10n/epo-RUS.h index e4d1536b6..fe5a2c9df 100644 --- a/src/l10n/epo-RUS.h +++ b/src/l10n/epo-RUS.h @@ -753,6 +753,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "Nenia tasko." diff --git a/src/l10n/esp-ESP.h b/src/l10n/esp-ESP.h index bdb809b49..863757178 100644 --- a/src/l10n/esp-ESP.h +++ b/src/l10n/esp-ESP.h @@ -765,6 +765,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "Ninguna tarea." diff --git a/src/l10n/fra-FRA.h b/src/l10n/fra-FRA.h index 1d92635df..20ca1cfb6 100644 --- a/src/l10n/fra-FRA.h +++ b/src/l10n/fra-FRA.h @@ -753,6 +753,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "No tasks." diff --git a/src/l10n/ita-ITA.h b/src/l10n/ita-ITA.h index 094f1a3fc..925d0025c 100644 --- a/src/l10n/ita-ITA.h +++ b/src/l10n/ita-ITA.h @@ -752,6 +752,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "Nessun task." diff --git a/src/l10n/jpn-JPN.h b/src/l10n/jpn-JPN.h index bc4a59c93..2191fa84d 100644 --- a/src/l10n/jpn-JPN.h +++ b/src/l10n/jpn-JPN.h @@ -753,6 +753,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "タスクがない。" diff --git a/src/l10n/pol-POL.h b/src/l10n/pol-POL.h index 148a0b717..b3bc47143 100644 --- a/src/l10n/pol-POL.h +++ b/src/l10n/pol-POL.h @@ -753,6 +753,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "Brak zadań." diff --git a/src/l10n/por-PRT.h b/src/l10n/por-PRT.h index 4486c62f8..423d18ea9 100644 --- a/src/l10n/por-PRT.h +++ b/src/l10n/por-PRT.h @@ -753,6 +753,7 @@ #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made." +#define STRING_ERROR_BAD_STATUS "The status '{1}' is not valid." // Feedback #define STRING_FEEDBACK_NO_TASKS "Nenhuma tarefa."