Strip trailing newline from address book entries without names
When the list of completions from the external command doesn't have associated contact names, the email address we attempt to parse was being terminated with a newline. Now, we strip the trailing newline if present.
This commit is contained in:
parent
eca3863242
commit
598e39f523
1 changed files with 11 additions and 9 deletions
|
@ -138,7 +138,10 @@ func readCompletions(r io.Reader) ([]string, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
parts := strings.SplitN(line, "\t", 3)
|
parts := strings.SplitN(line, "\t", 3)
|
||||||
if addr, err := mail.ParseAddress(parts[0]); err == nil {
|
addr, err := mail.ParseAddress(strings.TrimSpace(parts[0]))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
addr.Name = strings.TrimSpace(parts[1])
|
addr.Name = strings.TrimSpace(parts[1])
|
||||||
}
|
}
|
||||||
|
@ -149,7 +152,6 @@ func readCompletions(r io.Reader) ([]string, error) {
|
||||||
completions = append(completions, decoded)
|
completions = append(completions, decoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func decodeMIME(s string) (string, error) {
|
func decodeMIME(s string) (string, error) {
|
||||||
var d mime.WordDecoder
|
var d mime.WordDecoder
|
||||||
|
|
Loading…
Reference in a new issue