diff --git a/mitmproxy/lexer.py b/mitmproxy/lexer.py index a7024ca22..f123a8384 100644 --- a/mitmproxy/lexer.py +++ b/mitmproxy/lexer.py @@ -90,9 +90,6 @@ class Lexer: acc += ch else: acc += ch - else: - print("This shouldn't have happened") - exit(-1) self._token = acc diff --git a/test/mitmproxy/test_lexer.py b/test/mitmproxy/test_lexer.py index ae706407e..a1898620e 100644 --- a/test/mitmproxy/test_lexer.py +++ b/test/mitmproxy/test_lexer.py @@ -1,5 +1,6 @@ from mitmproxy import lexer import pytest +import io class TestScripts: @@ -47,6 +48,10 @@ class TestScripts: "text": '\n\n\rHello\n World With Spaces\n\n', "result": ['Hello', 'World', 'With', 'Spaces'] }, + { + "text": r'\" Escaping characters without reason', + "result": ['\\"', 'Escaping', 'characters', 'without', 'reason'] + }, ] for t in cases: @@ -61,3 +66,12 @@ class TestScripts: lex = lexer.Lexer(text) with pytest.raises(ValueError, match="No closing quotation"): assert list(lex) + + def test_stringio_text(self): + text = io.StringIO(r'Increase test coverage') + lex = lexer.Lexer(text) + tokens = list(lex) + result = ['Increase', 'test', 'coverage'] + assert(tokens == result) + +