diff options
| author | Shulhan <ms@kilabit.info> | 2019-03-26 02:44:10 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-03-26 02:44:10 +0700 |
| commit | 19e6d4ac045e9ca42f74e36d283e7b89e64d02e9 (patch) | |
| tree | 58abf49609fc7a7e271947d1ce47e5f56fecfe9d | |
| parent | a4c0f6e3bbf0b3e418abb34acc8811f50b0f0deb (diff) | |
| download | pakakeh.go-19e6d4ac045e9ca42f74e36d283e7b89e64d02e9.tar.xz | |
smtp: fix parsing local-part to allow special characters
Previously, passing "#abcd" to parseLocalDomain will return nil, because
the loop end without any check if special character is found or not.
This commit fix it by setting local variable "found" to true, when
we found the special characters and continue after it..
| -rw-r--r-- | lib/smtp/smtp.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/smtp/smtp.go b/lib/smtp/smtp.go index 46970796..9705be89 100644 --- a/lib/smtp/smtp.go +++ b/lib/smtp/smtp.go @@ -185,7 +185,10 @@ func parseLocalDomain(data []byte, allow []byte) (out []byte) { if data[0] == '.' || data[len(data)-1] == '.' { return nil } - isDot := false + var ( + found bool + isDot bool + ) for x := 0; x < len(data); x++ { if data[x] == '(' { x = skipComment(data, x) @@ -205,12 +208,17 @@ func parseLocalDomain(data []byte, allow []byte) (out []byte) { out = append(out, data[x]) continue } + found = false for _, c := range allow { if c == data[x] { out = append(out, data[x]) + found = true break } } + if found { + continue + } if data[x] == '.' { isDot = true continue |
