diff --git a/NEWS b/NEWS index 65184d0b6..cc9b5fe59 100644 --- a/NEWS +++ b/NEWS @@ -2,10 +2,11 @@ New Features in taskwarrior 2.4.1 - New German translation. + - Hook scripts are now under much stricter control. New commands in taskwarrior 2.4.1 - - + - None New configuration options in taskwarrior 2.4.1 @@ -17,11 +18,11 @@ New configuration options in taskwarrior 2.4.1 Newly deprecated features in taskwarrior 2.4.1 - - + - None Removed features in 2.4.1 - - + - None Known Issues diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 19249ffe3..54519f99a 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -144,6 +144,8 @@ void Hooks::onLaunch () } else { + assertFeedback (outputFeedback); + std::vector ::iterator message; for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message) context.error (*message); @@ -209,6 +211,8 @@ void Hooks::onExit () } else { + assertFeedback (outputFeedback); + std::vector ::iterator message; for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message) context.error (*message); @@ -273,6 +277,8 @@ void Hooks::onAdd (Task& task) } else { + assertFeedback (outputFeedback); + std::vector ::iterator message; for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message) context.error (*message); @@ -342,6 +348,8 @@ void Hooks::onModify (const Task& before, Task& after) } else { + assertFeedback (outputFeedback); + std::vector ::iterator message; for (message = outputFeedback.begin (); message != outputFeedback.end (); ++message) context.error (*message); @@ -493,6 +501,22 @@ void Hooks::assertSameTask (const std::vector & input, const Task& } } +//////////////////////////////////////////////////////////////////////////////// +void Hooks::assertFeedback (const std::vector & input) const +{ + bool foundSomething = false; + std::vector ::const_iterator i; + for (i = input.begin (); i != input.end (); ++i) + if (nontrivial (*i)) + foundSomething = true; + + if (! foundSomething) + { + context.error ("Hook Error: Expected feedback from a failing hook script."); + throw 0; + } +} + //////////////////////////////////////////////////////////////////////////////// int Hooks::callHookScript ( const std::string& script, diff --git a/src/Hooks.h b/src/Hooks.h index 4737b3a96..37807824e 100644 --- a/src/Hooks.h +++ b/src/Hooks.h @@ -56,6 +56,7 @@ private: void assertValidJSON (const std::vector &) const; void assertNTasks (const std::vector &, int) const; void assertSameTask (const std::vector &, const Task&) const; + void assertFeedback (const std::vector &) const; int callHookScript (const std::string&, const std::vector &, std::vector &); private: