mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-10 12:46:46 +00:00
Validate recipient emails in send before asking for their public keys
This commit is contained in:
@ -3,6 +3,13 @@
|
|||||||
Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
## unreleased
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* GODT-308 better user error message when request is canceled
|
||||||
|
* GODT-312 validate recipient emails in send before asking for their public keys
|
||||||
|
|
||||||
|
## [v1.2.7] Donghai-hotfix - beta (2020-05-07)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* IMAP mailbox info update when new mailbox is created
|
* IMAP mailbox info update when new mailbox is created
|
||||||
|
|||||||
@ -209,6 +209,10 @@ func (su *smtpUser) Send(from string, to []string, messageReader io.Reader) (err
|
|||||||
containsUnencryptedRecipients := false
|
containsUnencryptedRecipients := false
|
||||||
|
|
||||||
for _, email := range to {
|
for _, email := range to {
|
||||||
|
if !looksLikeEmail(email) {
|
||||||
|
return errors.New(`"` + email + `" is not a valid recipient.`)
|
||||||
|
}
|
||||||
|
|
||||||
// PMEL 1.
|
// PMEL 1.
|
||||||
contactEmails, err := su.client.GetContactEmailByEmail(email, 0, 1000)
|
contactEmails, err := su.client.GetContactEmailByEmail(email, 0, 1000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -19,11 +19,23 @@ package smtp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
pmcrypto "github.com/ProtonMail/gopenpgp/crypto"
|
pmcrypto "github.com/ProtonMail/gopenpgp/crypto"
|
||||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:gochecknoglobals // Used like a constant
|
||||||
|
var mailFormat = regexp.MustCompile(`.+@.+\..+`)
|
||||||
|
|
||||||
|
// looksLikeEmail validates whether the string resembles an email.
|
||||||
|
//
|
||||||
|
// Notice that it does this naively by simply checking for the existence
|
||||||
|
// of a DOT and an AT sign.
|
||||||
|
func looksLikeEmail(e string) bool {
|
||||||
|
return mailFormat.MatchString(e)
|
||||||
|
}
|
||||||
|
|
||||||
func createPackets(
|
func createPackets(
|
||||||
pubkey *pmcrypto.KeyRing,
|
pubkey *pmcrypto.KeyRing,
|
||||||
bodyKey *pmcrypto.SymmetricKey,
|
bodyKey *pmcrypto.SymmetricKey,
|
||||||
|
|||||||
Reference in New Issue
Block a user