From 406f77efe2b07c532598aba43a6f6c72eeb4ad4b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 23 Jan 2016 15:21:44 -0500 Subject: [PATCH] Bug: Fixed bug where 'rc.allow.empty.filter' was not behaving properly - Thanks to Scott Kostyshak. --- ChangeLog | 2 ++ src/Filter.cpp | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5507cfe0..71b45e1da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -59,6 +59,8 @@ - Numerous performance improvements. Taskwarrior 2.5.1 is between X% and Y% faster than 2.5.0 when running various commands. - New formatting specifier 'relative' for columns of Date type was introduced. +- Fixed bug where 'rc.allow.empty.filter' was not behaving properly (thanks to + Scott Kostyshak). - Improved OpenBSD support (thanks to Kent R. Spillner). ------ current release --------------------------- diff --git a/src/Filter.cpp b/src/Filter.cpp index a199cdcd3..e4f6114d1 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -273,27 +273,31 @@ void Filter::safety () { if (_safety) { + bool readonly = true; + bool filter = false; for (auto& a : context.cli2._args) { - if (a.hasTag ("CMD")) - { - if (! a.hasTag ("READONLY")) - { - if (! context.config.getBoolean ("allow.empty.filter")) - throw std::string (STRING_TASK_SAFETY_ALLOW); + if (a.hasTag ("CMD") && + ! a.hasTag ("READONLY")) + readonly = false; - // If user is willing to be asked, this can be avoided. - if (context.config.getBoolean ("confirmation") && - confirm (STRING_TASK_SAFETY_VALVE)) - return; + if (a.hasTag ("FILTER")) + filter = true; + } - // Sounds the alarm. - throw std::string (STRING_TASK_SAFETY_FAIL); - } + if (! readonly && + ! filter) + { + if (! context.config.getBoolean ("allow.empty.filter")) + throw std::string (STRING_TASK_SAFETY_ALLOW); - // CMD was found. + // If user is willing to be asked, this can be avoided. + if (context.config.getBoolean ("confirmation") && + confirm (STRING_TASK_SAFETY_VALVE)) return; - } + + // Sound the alarm. + throw std::string (STRING_TASK_SAFETY_FAIL); } } }