fix(GODT-2582): Update Gluon for updated GetMessageHash

This patch also update getMessageHash to use the fixed version in Gluon.

https://github.com/ProtonMail/gluon/pull/342
This commit is contained in:
Leander Beernaert
2023-04-26 14:53:38 +02:00
parent ae7621ed6a
commit d8fa2fb3e3
3 changed files with 4 additions and 73 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.18
require (
github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557
github.com/Masterminds/semver/v3 v3.2.0
github.com/ProtonMail/gluon v0.16.1-0.20230425073628-8ec759b512f1
github.com/ProtonMail/gluon v0.16.1-0.20230426114906-aed4b8adf482
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a
github.com/ProtonMail/go-proton-api v0.4.1-0.20230426081144-f77778bae1be
github.com/ProtonMail/gopenpgp/v2 v2.7.1-proton

4
go.sum
View File

@ -28,8 +28,8 @@ github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf h1:yc9daCCYUefEs
github.com/ProtonMail/bcrypt v0.0.0-20211005172633-e235017c1baf/go.mod h1:o0ESU9p83twszAU8LBeJKFAAMX14tISa0yk4Oo5TOqo=
github.com/ProtonMail/docker-credential-helpers v1.1.0 h1:+kvUIpwWcbtP3WFv5sSvkFn/XLzSqPOB5AAthuk9xPk=
github.com/ProtonMail/docker-credential-helpers v1.1.0/go.mod h1:mK0aBveCxhnQ756AmaTfXMZDeULvheYVhF/MWMErN5g=
github.com/ProtonMail/gluon v0.16.1-0.20230425073628-8ec759b512f1 h1:6YTRwn95hnTymOz5g+MbikfJXYE4xGJkIgTLm0t/1w8=
github.com/ProtonMail/gluon v0.16.1-0.20230425073628-8ec759b512f1/go.mod h1:yA4hk6CJw0BMo+YL8Y3ckCYs5L20sysu9xseshwY3QI=
github.com/ProtonMail/gluon v0.16.1-0.20230426114906-aed4b8adf482 h1:GvaYoE4Nj/l9L7hQnhGlu9s+IP6oqb4YPKR37GAjE+Y=
github.com/ProtonMail/gluon v0.16.1-0.20230426114906-aed4b8adf482/go.mod h1:yA4hk6CJw0BMo+YL8Y3ckCYs5L20sysu9xseshwY3QI=
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a h1:D+aZah+k14Gn6kmL7eKxoo/4Dr/lK3ChBcwce2+SQP4=
github.com/ProtonMail/go-autostart v0.0.0-20210130080809-00ed301c8e9a/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4=
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=

View File

@ -18,10 +18,7 @@
package user
import (
"bytes"
"context"
"crypto/sha256"
"encoding/base64"
"errors"
"fmt"
"sync"
@ -219,73 +216,7 @@ func (h *sendRecorder) getWaitCh(hash string) (<-chan struct{}, bool) {
// - the Content-Disposition header of each (leaf) part,
// - the (decoded) body of each part.
func getMessageHash(b []byte) (string, error) {
section := rfc822.Parse(b)
header, err := section.ParseHeader()
if err != nil {
return "", err
}
h := sha256.New()
if _, err := h.Write([]byte(header.Get("Subject"))); err != nil {
return "", err
}
if _, err := h.Write([]byte(header.Get("From"))); err != nil {
return "", err
}
if _, err := h.Write([]byte(header.Get("To"))); err != nil {
return "", err
}
if _, err := h.Write([]byte(header.Get("Cc"))); err != nil {
return "", err
}
if _, err := h.Write([]byte(header.Get("Reply-To"))); err != nil {
return "", err
}
if _, err := h.Write([]byte(header.Get("In-Reply-To"))); err != nil {
return "", err
}
if err := section.Walk(func(section *rfc822.Section) error {
children, err := section.Children()
if err != nil {
return err
} else if len(children) > 0 {
return nil
}
header, err := section.ParseHeader()
if err != nil {
return err
}
if _, err := h.Write([]byte(header.Get("Content-Type"))); err != nil {
return err
}
if _, err := h.Write([]byte(header.Get("Content-Disposition"))); err != nil {
return err
}
body := section.Body()
body = bytes.ReplaceAll(body, []byte{'\r'}, nil)
body = bytes.TrimSpace(body)
if _, err := h.Write(body); err != nil {
return err
}
return nil
}); err != nil {
return "", err
}
return base64.StdEncoding.EncodeToString(h.Sum(nil)), nil
return rfc822.GetMessageHash(b)
}
func matchToList(a, b []string) bool {