mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 04:36:43 +00:00
fix(GODT-2797): encode attached key name and use same pubkey name as web-app.
This commit is contained in:
@ -138,7 +138,11 @@ func (s *Service) smtpSendMail(ctx context.Context, authID string, from string,
|
|||||||
return fmt.Errorf("failed to get public key: %w", err)
|
return fmt.Errorf("failed to get public key: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.AttachPublicKey(pubKey, fmt.Sprintf("publickey - %v - %v", addrKR.GetIdentities()[0].Name, key.GetFingerprint()[:8]))
|
parser.AttachPublicKey(pubKey, fmt.Sprintf(
|
||||||
|
"publickey - %v - 0x%v",
|
||||||
|
addrKR.GetIdentities()[0].Name,
|
||||||
|
strings.ToUpper(key.GetFingerprint()[:8]),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the message we want to send (after we have attached the public key).
|
// Parse the message we want to send (after we have attached the public key).
|
||||||
|
|||||||
@ -18,8 +18,8 @@
|
|||||||
package parser
|
package parser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
|
"mime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/emersion/go-message"
|
"github.com/emersion/go-message"
|
||||||
@ -70,10 +70,12 @@ func (p *Parser) Root() *Part {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Parser) AttachPublicKey(key, keyName string) {
|
func (p *Parser) AttachPublicKey(key, keyName string) {
|
||||||
h := message.Header{}
|
encName := mime.QEncoding.Encode("utf-8", keyName+".asc")
|
||||||
|
params := map[string]string{"name": encName, "filename": encName}
|
||||||
|
|
||||||
h.Set("Content-Type", fmt.Sprintf(`application/pgp-keys; name="%v.asc"; filename="%v.asc"`, keyName, keyName))
|
h := message.Header{}
|
||||||
h.Set("Content-Disposition", fmt.Sprintf(`attachment; name="%v.asc"; filename="%v.asc"`, keyName, keyName))
|
h.Set("Content-Type", mime.FormatMediaType("application/pgp-keys", params))
|
||||||
|
h.Set("Content-Disposition", mime.FormatMediaType("attachment", params))
|
||||||
h.Set("Content-Transfer-Encoding", "base64")
|
h.Set("Content-Transfer-Encoding", "base64")
|
||||||
|
|
||||||
p.Root().AddChild(&Part{
|
p.Root().AddChild(&Part{
|
||||||
|
|||||||
Reference in New Issue
Block a user