From 7c6af7b65f5e1abb41d9be2dc8a3f0d1471f32f3 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 6 Apr 2023 19:12:42 +0200 Subject: pkg/email: handle bufio.ErrTooLong bufio.Scanner has a limit on the maximum line size. Don't panic in this case. --- pkg/email/patch.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/email/patch.go b/pkg/email/patch.go index 67ea9005a..8af5e1b79 100644 --- a/pkg/email/patch.go +++ b/pkg/email/patch.go @@ -33,7 +33,14 @@ func ParsePatch(message []byte) (diff string) { } } } - if err := s.Err(); err != nil { + err := s.Err() + if err == bufio.ErrTooLong { + // It's a problem of the incoming patch, rather than anything else. + // Anyway, if a patch contains too long lines, we're probably not + // interested in it, so let's pretent we didn't see it. + diff = "" + return + } else if err != nil { panic("error while scanning from memory: " + err.Error()) } return -- cgit mrf-deployment