Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email address parser #207

Open
4k7 opened this issue Apr 26, 2020 · 2 comments
Open

Email address parser #207

4k7 opened this issue Apr 26, 2020 · 2 comments

Comments

@4k7
Copy link

4k7 commented Apr 26, 2020

Hi,

If the email address with quotes in the name is parsed (for example, "Gogh Fir" <[email protected]>), 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" <[email protected]>`)
	if err == nil {
		log.Println(addr.DisplayName)
		log.Println(addr.String())
	}
}

Gogh Fir
"tesst"@test.com

@flashmob
Copy link
Owner

flashmob commented Apr 26, 2020 via email

@4k7
Copy link
Author

4k7 commented Apr 26, 2020

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
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants