~renerocksai/aercbook

8f6c4829b04054b7f8ec42192c3c6000bb169a1b — Max Schillinger a month ago c4769be
Fix parser crash on header lines shorter than 5 characters

This crash happens at header lines like

X-Provags-ID: V02:K0:jLG+n5RvqvXDfnaT86MCMCzjw0nIUzH7tOoFF3O0git
 nBPsfi4RZ56LhzW8NuyICLlpqUs+VgNKykpfuZo5jHVjY53Qw=
 =
1 files changed, 3 insertions(+), 3 deletions(-)

M src/main.zig
M src/main.zig => src/main.zig +3 -3
@@ 297,19 297,19 @@ fn parseMailFromStdin(alloc: std.mem.Allocator) !ParseMailResult {
            break;
        }

        if (std.ascii.eqlIgnoreCase(line[0..5], "from:")) {
        if (std.ascii.startsWithIgnoreCase(line, "from:")) {
            from_pos = it.index.? - line.len + 4;
            current_end = &from_end;
            from_end = it.index.? - 2;
            continue;
        }
        if (std.ascii.eqlIgnoreCase(line[0..3], "to:")) {
        if (std.ascii.startsWithIgnoreCase(line, "to:")) {
            to_pos = it.index.? - line.len + 2;
            current_end = &to_end;
            to_end = it.index.? - 2;
            continue;
        }
        if (std.ascii.eqlIgnoreCase(line[0..3], "cc:")) {
        if (std.ascii.startsWithIgnoreCase(line, "cc:")) {
            cc_pos = it.index.? - line.len + 2;
            current_end = &cc_end;
            cc_end = it.index.? - 2;