mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 15:46:44 +00:00
fix(BRIDGE-301): don't use external, non-BYOE addresses for imports
This commit is contained in:
@ -878,6 +878,15 @@ func (s *Connector) getImportAddress(p *parser.Parser, isDraft bool) (proton.Add
|
|||||||
return proton.Address{}, errors.New("could not find account address")
|
return proton.Address{}, errors.New("could not find account address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the address is external and not BYOE - with sending enabled, then use the primary address as an import target.
|
||||||
|
if address.Type == proton.AddressTypeExternal && !address.Send {
|
||||||
|
var err error
|
||||||
|
address, err = s.identityState.GetPrimaryAddress()
|
||||||
|
if err != nil {
|
||||||
|
return proton.Address{}, errors.New("could not get primary account address")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inCombinedMode := s.addressMode == usertypes.AddressModeCombined
|
inCombinedMode := s.addressMode == usertypes.AddressModeCombined
|
||||||
if !inCombinedMode {
|
if !inCombinedMode {
|
||||||
return address, nil
|
return address, nil
|
||||||
@ -903,7 +912,10 @@ func (s *Connector) getImportAddress(p *parser.Parser, isDraft bool) (proton.Add
|
|||||||
// - import with non-default disabled address in combined mode: using sender address
|
// - import with non-default disabled address in combined mode: using sender address
|
||||||
|
|
||||||
isSenderAddressDisabled := (!bool(senderAddr.Send)) || (senderAddr.Status != proton.AddressStatusEnabled)
|
isSenderAddressDisabled := (!bool(senderAddr.Send)) || (senderAddr.Status != proton.AddressStatusEnabled)
|
||||||
if isDraft && isSenderAddressDisabled {
|
// BRIDGE-301: forbid imports via sender address if it's external.
|
||||||
|
isSenderExternal := senderAddr.Type == proton.AddressTypeExternal
|
||||||
|
|
||||||
|
if (isDraft && isSenderAddressDisabled) || isSenderExternal {
|
||||||
return address, nil
|
return address, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user