Commit bd1efd50 authored by MathiasB's avatar MathiasB Committed by Russ Cox

net/mail: fixed quoted-local

Fixes some minor issues regarding quoted-string when parsing
the local-part.

Those strings should return an error:
- quoted-string without any content: `""@test.com`
- quoted-string containing tab: "\"\t\"@test.com"

Fixes #11293

Change-Id: Ied93eb6831915c9b1f8e727cea14168af21f8d3b
Reviewed-on: https://go-review.googlesource.com/12905Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 782eea01
......@@ -419,7 +419,7 @@ Loop:
}
qsb = append(qsb, p.s[i+1])
i += 2
case isQtext(c), c == ' ' || c == '\t':
case isQtext(c), c == ' ':
// qtext (printable US-ASCII excluding " and \), or
// FWS (almost; we're ignoring CRLF)
qsb = append(qsb, c)
......@@ -429,6 +429,9 @@ Loop:
}
}
p.s = p.s[i+1:]
if len(qsb) == 0 {
return "", errors.New("mail: empty quoted-string")
}
return string(qsb), nil
}
......
......@@ -522,6 +522,7 @@ func TestAddressParsingAndFormatting(t *testing.T) {
`<".john.doe"@example.com>`,
`<"."@example.com>`,
`<".."@example.com>`,
`<"0:"@0>`,
}
for _, test := range tests {
......@@ -563,6 +564,8 @@ func TestAddressParsingAndFormatting(t *testing.T) {
`<test@.>`,
`< @example.com>`,
`<""test""blah""@example.com>`,
`<""@0>`,
"<\"\t0\"@0>",
}
for _, test := range badTests {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment