Improve log upload handling
This commit is contained in:
@@ -28,3 +28,33 @@ def test_parse_log_file_rejects_tokens_without_equals():
|
||||
|
||||
with pytest.raises(LogParseError):
|
||||
parse_log_file(stream)
|
||||
|
||||
|
||||
def test_parse_log_file_supports_utf8_bom():
|
||||
stream = io.BytesIO(
|
||||
b'\xef\xbb\xbfv015xxxxdate=2024-02-15 time=09:10:11 msg="blocked request"\n'
|
||||
)
|
||||
|
||||
records, _union_keys = parse_log_file(stream)
|
||||
|
||||
assert records[0]["v015xxxxdate"] == "2024-02-15"
|
||||
|
||||
|
||||
def test_parse_log_file_supports_cp1252_text():
|
||||
stream = io.BytesIO(
|
||||
'v015xxxxdate=2024-02-15 time=09:10:11 msg="caf\xe9 request"\n'.encode("cp1252")
|
||||
)
|
||||
|
||||
records, _union_keys = parse_log_file(stream)
|
||||
|
||||
assert records[0]["msg"] == "cafe request".replace("e", "é", 1)
|
||||
|
||||
|
||||
def test_parse_log_file_tolerates_unterminated_quotes():
|
||||
stream = io.BytesIO(
|
||||
b'v015xxxxdate=2024-02-15 time=09:10:11 msg="broken quoted value\n'
|
||||
)
|
||||
|
||||
records, _union_keys = parse_log_file(stream)
|
||||
|
||||
assert records[0]["msg"] == "broken quoted value"
|
||||
|
||||
Reference in New Issue
Block a user