From d85901e7ff0ce0aec8e6090dd601552b08f61007 Mon Sep 17 00:00:00 2001 From: Max Rossmannek Date: Sat, 28 Nov 2020 14:21:16 +0100 Subject: [PATCH] Properly escape filters including spaces This adds a note to the man page to properly escape filters containing spaces. It also fixes the unittests to reflect this. One of the unittests contained an alternative syntax as discussed in TW-1479 (#1505). It has been extracted into its own unittest and marked as an expected failure because it is currently not supported. --- doc/man/task.1.in | 4 ++++ test/filter.t | 2 +- test/project.t | 2 +- test/search.t | 10 ++++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/man/task.1.in b/doc/man/task.1.in index 9b95d49cc..941058fb8 100644 --- a/doc/man/task.1.in +++ b/doc/man/task.1.in @@ -75,6 +75,10 @@ UUID numbers or ID ranges): task 1 2-5 19 modify pri:H task 4-7 ebeeab00-ccf8-464b-8b58-f7f2d606edfb info +Note that it may be necessary to properly escape special characters as well as +quotes in order to avoid their special meanings in the shell. See also the +section 'SPECIFYING DESCRIPTIONS' for more information. + .SH MODIFICATIONS The consist of zero or more changes to apply to the selected tasks, such diff --git a/test/filter.t b/test/filter.t index 05024e91d..303cfc05c 100755 --- a/test/filter.t +++ b/test/filter.t @@ -670,7 +670,7 @@ class TestBug1600(TestCase): self.assertIn("foobar1", out) self.assertIn("foobar2", out) - code, out, err = self.t("all description.contains:'foobar\\+'") + code, out, err = self.t(r"all description.contains:\'foobar\\+\'") self.assertIn("foobar+", out) self.assertNotIn("foobar1", out) self.assertNotIn("foobar2", out) diff --git a/test/project.t b/test/project.t index c1c0c6364..61eb6aab4 100755 --- a/test/project.t +++ b/test/project.t @@ -464,7 +464,7 @@ class TestBug1617(TestCase): self.t("add one") self.t("add two project:'three four'") - code, out, err = self.t("project:'three four' list") + code, out, err = self.t(r"project:\'three\ four\' list") self.assertIn("two", out) self.assertNotIn("one", out) diff --git a/test/search.t b/test/search.t index 2e2374ba2..b53ca50dd 100755 --- a/test/search.t +++ b/test/search.t @@ -254,11 +254,17 @@ class TestBug1479(TestCase): self.t("add project:P1 one") self.t("add project:P2 one two") - code, out, err = self.t("description:one\ two list") + code, out, err = self.t(r"description:\'one\ two\' list") self.assertNotIn("P1", out) self.assertIn("P2", out) - code, out, err = self.t("description:'one two' list") + @unittest.expectedFailure + def test_description_with_spaces_alternative_syntax(self): + """1479: Alternative syntax""" + self.t("add project:P1 one") + self.t("add project:P2 one two") + + code, out, err = self.t("description:one\ two list") self.assertNotIn("P1", out) self.assertIn("P2", out)