Skip to content

Commit

Permalink
check that parsed email matches user's argument
Browse files Browse the repository at this point in the history
  • Loading branch information
btoews committed Apr 12, 2019
1 parent 803db3b commit ba92743
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (m *mkcert) makeCert(hosts []string) {
for _, h := range hosts {
if ip := net.ParseIP(h); ip != nil {
tpl.IPAddresses = append(tpl.IPAddresses, ip)
} else if email, err := mail.ParseAddress(h); err == nil {
tpl.EmailAddresses = append(tpl.EmailAddresses, email.Address)
} else if email, err := mail.ParseAddress(h); err == nil && email.Address == h {
tpl.EmailAddresses = append(tpl.EmailAddresses, h)
} else {
tpl.DNSNames = append(tpl.DNSNames, h)
}
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ func (m *mkcert) Run(args []string) {
if ip := net.ParseIP(name); ip != nil {
continue
}
if email, err := mail.ParseAddress(name); err == nil {
args[i] = email.Address
if email, err := mail.ParseAddress(name); err == nil && email.Address == name {
continue
}
punycode, err := idna.ToASCII(name)
Expand Down

0 comments on commit ba92743

Please sign in to comment.