net/mail: parses invalid address
dvyukov opened this issue · 7 comments
dvyukov commented
The following program fails with the panic:
package main
import (
"fmt"
"net/mail"
)
func main() {
data := "\"\"@0"
addr, err := mail.ParseAddress(data)
if err != nil {
return
}
_, err = mail.ParseAddress(addr.String())
if err != nil {
fmt.Printf("failed to parse addr: %q -> %q\n", data, addr)
panic(err)
}
}
failed to parse addr: "\"\"@0" -> "<@0>"
panic: mail: invalid string
I guess that address should have not been parsed in the first place.
go version devel +514014c Thu Jun 18 15:54:35 2015 +0200 linux/amd64
dvyukov commented
This is probably the same issue:
data := "\"0:\"@0"
but worth a separate test.
dvyukov commented
One more:
data := "\"\t0\"@0"
DenBeke commented
What is wrong with data := "\"0:\"@0"
?
dvyukov commented
It does not parse successfully in the second mail.ParseAddress call. Either first mail.ParseAddress or String corrupt it somehow, or it should not be parsed the first time as well.
DenBeke commented
gopherbot commented
CL https://golang.org/cl/12905 mentions this issue.
DenBeke commented
I uploaded a patch request for this issue...
https://golang.org/cl/12905