forked from External/ergo
bump irc-go to v0.5.0-rc2 (#2194)
This commit is contained in:
parent
7586520032
commit
9577e87d9a
5 changed files with 46 additions and 24 deletions
20
vendor/github.com/ergochat/irc-go/ircmsg/message.go
generated
vendored
20
vendor/github.com/ergochat/irc-go/ircmsg/message.go
generated
vendored
|
|
@ -196,6 +196,15 @@ func trimInitialSpaces(str string) string {
|
|||
return str[i:]
|
||||
}
|
||||
|
||||
func isASCII(str string) bool {
|
||||
for i := 0; i < len(str); i++ {
|
||||
if str[i] > 127 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg Message, err error) {
|
||||
// remove either \n or \r\n from the end of the line:
|
||||
line = strings.TrimSuffix(line, "\n")
|
||||
|
|
@ -265,11 +274,16 @@ func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg Messa
|
|||
commandEnd = len(line)
|
||||
paramStart = len(line)
|
||||
}
|
||||
// normalize command to uppercase:
|
||||
ircmsg.Command = strings.ToUpper(line[:commandEnd])
|
||||
if len(ircmsg.Command) == 0 {
|
||||
baseCommand := line[:commandEnd]
|
||||
if len(baseCommand) == 0 {
|
||||
return ircmsg, ErrorLineIsEmpty
|
||||
}
|
||||
// technically this must be either letters or a 3-digit numeric:
|
||||
if !isASCII(baseCommand) {
|
||||
return ircmsg, ErrorLineContainsBadChar
|
||||
}
|
||||
// normalize command to uppercase:
|
||||
ircmsg.Command = strings.ToUpper(baseCommand)
|
||||
line = line[paramStart:]
|
||||
|
||||
for {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue