aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-04-06 19:12:42 +0200
committerAleksandr Nogikh <wp32pw@gmail.com>2023-04-07 09:46:50 +0200
commit7c6af7b65f5e1abb41d9be2dc8a3f0d1471f32f3 (patch)
tree9ab1f97e25dfbe174663169e15cb54fa49694242
parenta218e99e64f1fa1f609bfcec62c67c4f47ac6199 (diff)
pkg/email: handle bufio.ErrTooLong
bufio.Scanner has a limit on the maximum line size. Don't panic in this case.
-rw-r--r--pkg/email/patch.go9
1 files changed, 8 insertions, 1 deletions
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