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

net/mail: parses invalid address #11293

Closed
dvyukov opened this issue Jun 19, 2015 · 7 comments
Closed

net/mail: parses invalid address #11293

dvyukov opened this issue Jun 19, 2015 · 7 comments
Assignees
Milestone

Comments

@dvyukov
Copy link
Member

@dvyukov dvyukov commented Jun 19, 2015

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
Copy link
Member Author

@dvyukov dvyukov commented Jun 19, 2015

This is probably the same issue:

    data := "\"0:\"@0"

but worth a separate test.

@dvyukov
Copy link
Member Author

@dvyukov dvyukov commented Jun 19, 2015

One more:

    data := "\"\t0\"@0"
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 19, 2015
@DenBeke
Copy link
Contributor

@DenBeke DenBeke commented Jul 30, 2015

What is wrong with data := "\"0:\"@0" ?

@dvyukov
Copy link
Member Author

@dvyukov dvyukov commented Jul 30, 2015

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
Copy link
Contributor

@DenBeke DenBeke commented Jul 30, 2015

I recently did a patchrequest to fix that round trip issue #10768: daaa450 (will be included in Go 1.5 afaik)

First and third example should indeed fail to parse, which doesn't happen. If I find some time I can look into it, doesn't seem hard to solve.

@gopherbot
Copy link

@gopherbot gopherbot commented Jul 31, 2015

CL https://golang.org/cl/12905 mentions this issue.

@DenBeke
Copy link
Contributor

@DenBeke DenBeke commented Jul 31, 2015

I uploaded a patch request for this issue...
https://golang.org/cl/12905

@rsc rsc closed this in bd1efd5 Jul 31, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.6 Jul 31, 2015
@golang golang locked and limited conversation to collaborators Aug 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.