reorder regex so escaped strings match first
This commit is contained in:
parent
aa1bd2e161
commit
4e88571216
|
@ -14,9 +14,9 @@ _LOG_LINE = re.compile(
|
|||
r'count=(?P<count>\d+)$'
|
||||
)
|
||||
|
||||
_TOPICS = re.compile(r'((\w+=("[^"]+"|\S+) )+)?\w+=("([^"\\]|\\")+"|\S+)$')
|
||||
_TOPICS = re.compile(r'((\w+=("[^"]+"|\S+) )+)?\w+=("(\\"|[^"])+"|\S+)$')
|
||||
|
||||
_TOPICS_KV = re.compile(r'(?P<key>\w+)=(?P<value>"(?:[^"\\]|\\")+"|\S+)')
|
||||
_TOPICS_KV = re.compile(r'(?P<key>\w+)=(?P<value>"(?:\\"|[^"])+"|\S+)')
|
||||
|
||||
|
||||
class LogLevel(Enum):
|
||||
|
|
|
@ -86,3 +86,21 @@ def test_should_parse_topics_with_escaped_quotes_in_values():
|
|||
'topics': '"codex pendingblocks"',
|
||||
'address': '"cid: \\"zDx*QP4zx9\\""',
|
||||
}
|
||||
|
||||
|
||||
def test_should_parse_topics_with_escaped_quotes_and_backlashes_in_value():
|
||||
source = ChroniclesRawSource(
|
||||
StringLogSource(
|
||||
lines='TRC 2024-02-02 20:37:18.316+00:00 Starting codex node topics="codex node" '
|
||||
'config="some \\"quoted\\" string with \'more\' escape chars" count=7'
|
||||
)
|
||||
).__iter__()
|
||||
|
||||
line = next(source)
|
||||
|
||||
assert line.message == "Starting codex node"
|
||||
assert line.count == 7
|
||||
assert line.fields == {
|
||||
'topics': '"codex node"',
|
||||
'config': '"some \\"quoted\\" string with \'more\' escape chars"',
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "logtools"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
description = ""
|
||||
authors = ["gmega <giuliano@status.im>"]
|
||||
readme = "README.md"
|
||||
|
|
Loading…
Reference in New Issue