Created
December 7, 2020 13:31
-
-
Save execjosh/4f487c4f6dd23448c18ad3a20edd74f3 to your computer and use it in GitHub Desktop.
A ~hack~ patch to teach net/textproto how to ignore `050`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/net/textproto/reader.go b/src/net/textproto/reader.go | |
index a00fd2395f..9f82186c62 100644 | |
--- a/src/net/textproto/reader.go | |
+++ b/src/net/textproto/reader.go | |
@@ -10,6 +10,7 @@ import ( | |
"fmt" | |
"io" | |
"io/ioutil" | |
+ "log" | |
"strconv" | |
"strings" | |
"sync" | |
@@ -190,11 +191,20 @@ func (r *Reader) skipSpace() int { | |
} | |
func (r *Reader) readCodeLine(expectCode int) (code int, continued bool, message string, err error) { | |
- line, err := r.ReadLine() | |
- if err != nil { | |
- return | |
+ for { | |
+ line, err := r.ReadLine() | |
+ if err != nil { | |
+ return 0, false, "", err | |
+ } | |
+ code, continued, message, err = parseCodeLine(line, expectCode) | |
+ if err != nil { | |
+ if strings.HasPrefix(err.Error(), "invalid response code: 050") { | |
+ log.Println("[+] Skipping:", err.Error()) | |
+ continue | |
+ } | |
+ } | |
+ return code, continued, message, err | |
} | |
- return parseCodeLine(line, expectCode) | |
} | |
func parseCodeLine(line string, expectCode int) (code int, continued bool, message string, err error) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment