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

mail.Address.String() does not take care of non-ASCII name with comma #12782

Closed
cention-sany opened this issue Sep 29, 2015 · 3 comments
Closed

Comments

@cention-sany
Copy link

  1. go version 1.4.2
  2. Linux sanydellubuntu 3.19.0-30-generic log_test fails because of ??? filename #33-Ubuntu SMP Mon Sep 21 20:58:04 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  3. See my code below.
  4. I expected mail.Address.String() can escape the comma for non-ASCII characters.
  5. Comma is output without escape and cause error mail: no angle-addr during parsing.
package main

import (
    "log"
    "net/mail"
)

func formatEmailAddress(emailaddress, name string) string {
    a := new(mail.Address)
    if "" == emailaddress {
        return ""
    }
    a.Address = emailaddress
    if "" != name {
        a.Name = name
    }
    return a.String()
}

func main() {
    s := formatEmailAddress("test.mail@gmail.com", "naé, mée")
    log.Println(s)
    a, err := mail.ParseAddress(s)
    if nil != err {
        log.Println("error because:", err)
    } else {
        log.Println("name is:", a.Name, "email is:", a.Address)
    }
}
@alexcesaro
Copy link
Contributor

This is a duplicate of #11292. I will fix that bug when CL 14957 is merged.

@gopherbot
Copy link

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

@adg
Copy link
Contributor

adg commented Oct 20, 2015

Closing as dupe

@adg adg closed this as completed Oct 20, 2015
@golang golang locked and limited conversation to collaborators Oct 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants