diff options
| author | Pimyn Girgis <pimyn@google.com> | 2025-10-13 13:51:06 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-11-03 13:16:31 +0000 |
| commit | 317f89e1cd7cc8300ded51c3a24c8aa7839b52c8 (patch) | |
| tree | 7a5da3d6a5496cc26b0bbdfc3f81757d94441877 /pkg/email | |
| parent | 1b1dc2843ef942aab06c9afea214ae81d786c5b0 (diff) | |
pkg/email: parse diff more tolerably
Accept empty lines as part of a diff.
Fixes #6403
Diffstat (limited to 'pkg/email')
| -rw-r--r-- | pkg/email/patch.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/email/patch.go b/pkg/email/patch.go index 8af5e1b79..81ea9b26c 100644 --- a/pkg/email/patch.go +++ b/pkg/email/patch.go @@ -21,18 +21,22 @@ func ParsePatch(message []byte) (diff string) { continue } if diffStarted { - if ln == "" || ln == "--" || ln == "-- " || ln[0] == '>' { + if ln == "--" || ln == "-- " || ln != "" && ln[0] == '>' { diffStarted = false continue } - if strings.HasPrefix(ln, " ") || strings.HasPrefix(ln, "+") || + if ln == "" || strings.HasPrefix(ln, " ") || strings.HasPrefix(ln, "+") || strings.HasPrefix(ln, "-") || strings.HasPrefix(ln, "@") || strings.HasPrefix(ln, "================") { diff += ln + "\n" continue } + diffStarted = false } } + if diff != "" { + diff = strings.TrimRight(diff, "\n") + "\n" + } err := s.Err() if err == bufio.ErrTooLong { // It's a problem of the incoming patch, rather than anything else. |
