diff --git a/logtools/log/sources/parse/chronicles_raw_source.py b/logtools/log/sources/parse/chronicles_raw_source.py index e36cd5c..21918d6 100644 --- a/logtools/log/sources/parse/chronicles_raw_source.py +++ b/logtools/log/sources/parse/chronicles_raw_source.py @@ -14,9 +14,9 @@ _LOG_LINE = re.compile( r'count=(?P\d+)$' ) -_TOPICS = re.compile(r'((\w+=("[^"]+"|\S+) )+)?\w+=("[^"]+"|\S+)$') +_TOPICS = re.compile(r'((\w+=("[^"]+"|\S+) )+)?\w+=("([^"\\]|\\")+"|\S+)$') -_TOPICS_KV = re.compile(r'(?P\w+)=(?P"[^"]+"|\S+)') +_TOPICS_KV = re.compile(r'(?P\w+)=(?P"(?:[^"\\]|\\")+"|\S+)') class LogLevel(Enum): diff --git a/logtools/log/sources/parse/tests/test_chronicles_raw_source.py b/logtools/log/sources/parse/tests/test_chronicles_raw_source.py index c0db6c5..7addb4f 100644 --- a/logtools/log/sources/parse/tests/test_chronicles_raw_source.py +++ b/logtools/log/sources/parse/tests/test_chronicles_raw_source.py @@ -52,7 +52,7 @@ def test_should_parse_chronicles_fields(): } -def test_should_parse_topics_with_non_alphanumeric_characters(): +def test_should_parse_topics_with_non_alphanumeric_character_values(): source = ChroniclesRawSource( StringLogSource( lines='WRN 2024-02-02 20:38:47.316+00:00 a message topics="codex pendingblocks" address="cid: zDx*QP4zx9" ' @@ -68,3 +68,21 @@ def test_should_parse_topics_with_non_alphanumeric_characters(): 'topics': '"codex pendingblocks"', 'address': '"cid: zDx*QP4zx9"', } + + +def test_should_parse_topics_with_escaped_quotes_in_values(): + source = ChroniclesRawSource( + StringLogSource( + lines='WRN 2024-02-02 20:38:47.316+00:00 a message topics="codex pendingblocks" ' + 'address="cid: \\"zDx*QP4zx9\\"" count=10641' + ) + ).__iter__() + + line = next(source) + + assert line.message == "a message" + assert line.count == 10641 + assert line.fields == { + 'topics': '"codex pendingblocks"', + 'address': '"cid: \\"zDx*QP4zx9\\""', + } diff --git a/pyproject.toml b/pyproject.toml index e065258..94e92eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "logtools" -version = "1.1.1" +version = "1.1.2" description = "" authors = ["gmega "] readme = "README.md"