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/12905
Reviewed-by: Russ Cox <rsc@golang.org>
}
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)
}
}
p.s = p.s[i+1:]
+ if len(qsb) == 0 {
+ return "", errors.New("mail: empty quoted-string")
+ }
return string(qsb), nil
}
`<".john.doe"@example.com>`,
`<"."@example.com>`,
`<".."@example.com>`,
+ `<"0:"@0>`,
}
for _, test := range tests {
`<test@.>`,
`< @example.com>`,
`<""test""blah""@example.com>`,
+ `<""@0>`,
+ "<\"\t0\"@0>",
}
for _, test := range badTests {