Open 4k7 opened 4 years ago
Thanks for reporting this! It's a bug that needs to be addressed. Would you be interested in submitting a PR?
On Sun, 26 Apr 2020, 10:45 int01, notifications@github.com wrote:
Hi,
If the email address with quotes in the name is parsed (for example, "Gogh Fir" tesst@test.com), then the flag Quoted will be set, indicates then the local-part needs quotes too. As a result, String () will return "tesst" @ test.com.
This is due to the fact that the QcontentSMTP () function is called when parsing the name in quotation marks and mistakenly sets the flag for local part.
Thanks.
package main
import ( "log" "github.com/flashmob/go-guerrilla/mail" )
func main() { addr, err := mail.NewAddress(
"Gogh Fir" <tesst@test.com>
) if err == nil { log.Println(addr.DisplayName) log.Println(addr.String()) } }Gogh Fir "tesst"@test.com
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/flashmob/go-guerrilla/issues/207, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE6MP5ZLNSTY4L57W6VDLTROOG3DANCNFSM4MRAEH4Q .
It seems enough in the file "address.go" in the displayName() function add s.LocalPartQuotes = false.
func (s *RFC5322) displayName() error {
defer func() {
if s.accept.Len() > 0 {
s.addr.DisplayName = s.accept.String()
s.accept.Reset()
s.LocalPartQuotes = false // !!! THIS LINE !!!
}
}()
// phrase
if err := s.word(); err != nil {
return err
}
for {
err := s.word()
if err != nil {
return nil
}
}
}
Hi,
If the email address with quotes in the name is parsed (for example, "Gogh Fir" <tesst@test.com>), then the flag Quoted will be set, indicates then the local-part needs quotes too. As a result, String () will return "tesst" @ test.com.
This is due to the fact that the QcontentSMTP () function is called when parsing the name in quotation marks and mistakenly sets the flag for local part.
Thanks.