Do not decode a non-JSON value (#3859)

None of the other task modifications (modify, prepend, append) treat the
input as JSON, so this one shouldn't either. This works around
https://github.com/GothenburgBitFactory/libshared/issues/95
This commit is contained in:
Dustin J. Mitchell 2025-04-30 19:22:44 -04:00 committed by GitHub
parent 7be313e91f
commit b4e25fe42f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -928,7 +928,7 @@ void Task::addAnnotation(const std::string& description) {
++now; ++now;
} while (has(key)); } while (has(key));
data[key] = json::decode(description); data[key] = description;
++annotation_count; ++annotation_count;
recalc_urgency = true; recalc_urgency = true;
} }

View file

@ -67,21 +67,23 @@ class TestBug268(TestCase):
self.assertIn("a/b or c", out) self.assertIn("a/b or c", out)
class TestBug880(TestCase): class TestBug3858(TestCase):
def setUp(self): def setUp(self):
"""Executed before each test in the class""" """Executed before each test in the class"""
self.t = Task() self.t = Task()
def test_backslash_at_eol(self): def test_backslash_at_eol(self):
"""880: Backslash at end of description/annotation causes problems""" """880: Backslashes at end of description/annotation are handled correctly"""
self.t(r"add one\\") self.t(r"add one\\")
code, out, err = self.t("_get 1.description") code, out, err = self.t("_get 1.description")
self.assertEqual("one\\\n", out) self.assertEqual("one\\\n", out)
self.t(r"1 annotate 'two\\'") self.t(r"1 annotate 'two\'")
self.t(r"1 annotate 'three\\'")
code, out, err = self.t("info rc.verbose:nothing") code, out, err = self.t("info rc.verbose:nothing")
self.assertIn("one\\\n", out) self.assertIn("one\\\n", out)
self.assertIn("two\\\n", out) self.assertIn("two\\\n", out)
self.assertIn("three\\\\\n", out)
class TestBug1436(TestCase): class TestBug1436(TestCase):