mirror of
https://github.com/themasch/nginx-log-parser.git
synced 2025-02-13 12:10:28 +00:00
fix(format_parser): support two variables with no fixed part in between.
this will cause problems for the line parser, but its still possible to happen in the real world.
This commit is contained in:
parent
b2fdd96ccc
commit
fc804cb874
@ -155,6 +155,7 @@ fn read_byte(chr: u8, index: usize, state: &FormatParserState) -> FormatParserSt
|
||||
},
|
||||
Variable(start, _end) => match chr {
|
||||
x if is_var_char(x) => Variable(*start, index + 1),
|
||||
b'$' => Variable(index, index + 1),
|
||||
_ => Fixed(index, index + 1),
|
||||
},
|
||||
Fixed(start, _end) => match chr {
|
||||
@ -180,6 +181,9 @@ fn read_format(bytes: &[u8]) -> Result<Format, FormatParserError> {
|
||||
(Variable(start, end), Fixed(_, _)) => stack.push(FormatPart::Variable(
|
||||
create_owned_str(&bytes, *start, *end)?,
|
||||
)),
|
||||
(Variable(start, end), Variable(b_start, _)) if b_start > start => stack.push(FormatPart::Variable(
|
||||
create_owned_str(&bytes, *start, *end)?,
|
||||
)),
|
||||
(Fixed(start, end), Variable(_, _)) => {
|
||||
stack.push(FormatPart::Fixed(create_owned_str(&bytes, *start, *end)?))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user