#254: quotes in annotations are not escaped

Escapes the quotes for the annotations in the data file, and when
converting an interval to JSON.

The quotes in the annotations were already dequoted in
IntervalFactory::fromSerialization, so we only needed to quote the strings
when serializing or dumping to JSON.
This commit is contained in:
Shaun Ruffell 2019-11-13 04:47:55 -06:00 committed by lauft
parent 1d8b2aa042
commit 5f5cfb7b0f
2 changed files with 14 additions and 2 deletions

View file

@ -178,6 +178,18 @@ class TestAnnotate(TestCase):
self.assertEquals(len(j), 1)
self.assertClosedInterval(j[0], expectedAnnotation="foo")
def test_annotate_with_embedded_quotes(self):
"""Call 'annotate' with embedded quotes"""
now_utc = datetime.now().utcnow()
one_hour_before_utc = now_utc - timedelta(hours=1)
self.t("track {:%Y-%m-%dT%H:%M:%S}Z - {:%Y-%m-%dT%H:%M:%S}Z".format(one_hour_before_utc, now_utc))
self.t("annotate @1 'bar \"foo\" bar'")
j = self.t.export()
self.assertEquals(len(j), 1)
self.assertClosedInterval(j[0], expectedAnnotation='bar "foo" bar')
if __name__ == "__main__":
from simpletap import TAPTestRunner