From 51f08496b57cdd97350369f22bdee04d51796798 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 16 Oct 2014 20:49:39 -0400 Subject: [PATCH] Lexer - When parsing '\o/' the state Lexer::typeIdentifierEscape had no exit but a successful outcome, and looped. - Fixed test. --- ChangeLog | 1 + src/Lexer.cpp | 6 ++++++ test/tw-1436.t | 9 ++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7ce821a2..335ab7e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -167,6 +167,7 @@ - TW-1424 Using a date of '1824days' (in the future) fails (thanks to Black Ops Testing). - TW-1428 Add support for color.uda.. rules. +- TW-1436 Parser hangs when multiple slashes are used. - Removed deprecated 'echo.command' setting, in favor of the 'header' and 'affected' verbosity tokens. - Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 1ff303654..067c27818 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -244,6 +244,12 @@ bool Lexer::token (std::string& result, Type& type) type = typeEscapeUnicode; shift (); } + else + { + type = quote ? typeString : typeIdentifier; + result += utf8_character (_n0); + shift (); + } break; case typeEscape: diff --git a/test/tw-1436.t b/test/tw-1436.t index ff2190b26..5058374fa 100755 --- a/test/tw-1436.t +++ b/test/tw-1436.t @@ -15,7 +15,7 @@ class TestBug1436(TestCase): self.t = Task() def test_parser_hangs_with_slashes(self): - """Parser hangs with slashes""" + """Parser hangs with backslashes""" expected = "Cheer everyone up \o/" code, out, err = self.t(("add", expected)) self.assertIn("Created task 1", out) @@ -24,13 +24,12 @@ class TestBug1436(TestCase): self.assertIn(expected, out) def test_parser_ending_escape_slash(self): - """Task created but not found with ending slash""" - expected = "Use this slash \\" - code, out, err = self.t(("add", expected)) + """Task created but not found with ending backslash""" + code, out, err = self.t(("add", "Use this backslash \\\\")) self.assertIn("Created task 1", out) code, out, err = self.t(("list",)) - self.assertIn(expected, out) + self.assertIn("Use this backslash \\", out) if __name__ == "__main__":