Browse Source

bump irc-go to latest

tags/v2.6.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
a6f3e2c748

+ 1
- 1
go.mod View File

@@ -10,7 +10,7 @@ require (
10 10
 	github.com/go-sql-driver/mysql v1.5.0
11 11
 	github.com/go-test/deep v1.0.6 // indirect
12 12
 	github.com/gorilla/websocket v1.4.2
13
-	github.com/goshuirc/irc-go v0.0.0-20210222010959-6e139f6c42e9
13
+	github.com/goshuirc/irc-go v0.0.0-20210223005429-8d38e43fc6ed
14 14
 	github.com/onsi/ginkgo v1.12.0 // indirect
15 15
 	github.com/onsi/gomega v1.9.0 // indirect
16 16
 	github.com/oragono/confusables v0.0.0-20201108231250-4ab98ab61fb1

+ 2
- 0
go.sum View File

@@ -36,6 +36,8 @@ github.com/goshuirc/irc-go v0.0.0-20210215162435-14cd697c0c8c h1:pOTMO5A1nszuxNy
36 36
 github.com/goshuirc/irc-go v0.0.0-20210215162435-14cd697c0c8c/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
37 37
 github.com/goshuirc/irc-go v0.0.0-20210222010959-6e139f6c42e9 h1:A1mSQ0N5Kx8i+aeqeQ0VLbq3swuH0R/JoQcFcR9yUWA=
38 38
 github.com/goshuirc/irc-go v0.0.0-20210222010959-6e139f6c42e9/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
39
+github.com/goshuirc/irc-go v0.0.0-20210223005429-8d38e43fc6ed h1:cwwqHrmLafgEucSMC9PmFOA671dc4bEZ5z6FsamnBY8=
40
+github.com/goshuirc/irc-go v0.0.0-20210223005429-8d38e43fc6ed/go.mod h1:q/JhvvKLmif3y9q8MDQM+gRCnjEKnu5ClF298TTXJug=
39 41
 github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
40 42
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
41 43
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

+ 16
- 18
vendor/github.com/goshuirc/irc-go/ircmsg/message.go View File

@@ -9,7 +9,6 @@ import (
9 9
 	"bytes"
10 10
 	"errors"
11 11
 	"strings"
12
-	"unicode/utf8"
13 12
 )
14 13
 
15 14
 const (
@@ -41,8 +40,8 @@ var (
41 40
 	// (the name references 417 ERR_INPUTTOOLONG; we reserve the right to return it
42 41
 	// for messages that exceed the non-tag length limit)
43 42
 	ErrorLineTooLong = errors.New("Line could not be parsed because a specified length limit was exceeded")
44
-	// ErrorInvalidTagContent indicates that a tag value was invalid
45
-	ErrorInvalidTagContent = errors.New("Line could not be parsed because it contained an invalid tag value")
43
+	// ErrorInvalidTagContent indicates that a tag name or value was invalid
44
+	ErrorInvalidTagContent = errors.New("Line could not be processed because it contained an invalid tag name or value")
46 45
 
47 46
 	ErrorCommandMissing = errors.New("IRC messages MUST have a command")
48 47
 	ErrorBadParam       = errors.New("Cannot have an empty param, a param with spaces, or a param that starts with ':' before the last parameter")
@@ -168,19 +167,12 @@ func trimInitialSpaces(str string) string {
168 167
 }
169 168
 
170 169
 func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg IRCMessage, err error) {
171
-	if strings.IndexByte(line, '\x00') != -1 {
172
-		err = ErrorLineContainsBadChar
173
-		return
174
-	}
175
-
176
-	// trim to the first appearance of either '\r' or '\n':
177
-	lineEnd := strings.IndexByte(line, '\r')
178
-	newlineIndex := strings.IndexByte(line, '\n')
179
-	if newlineIndex != -1 && (lineEnd == -1 || newlineIndex < lineEnd) {
180
-		lineEnd = newlineIndex
181
-	}
182
-	if lineEnd != -1 {
183
-		line = line[:lineEnd]
170
+	// remove either \n or \r\n from the end of the line:
171
+	line = strings.TrimSuffix(line, "\n")
172
+	line = strings.TrimSuffix(line, "\r")
173
+	// now validate for the 3 forbidden bytes:
174
+	if strings.IndexByte(line, '\x00') != -1 || strings.IndexByte(line, '\n') != -1 || strings.IndexByte(line, '\r') != -1 {
175
+		return ircmsg, ErrorLineContainsBadChar
184 176
 	}
185 177
 
186 178
 	if len(line) < 1 {
@@ -285,8 +277,7 @@ func (ircmsg *IRCMessage) parseTags(tags string) (err error) {
285 277
 		// "Implementations [...] MUST NOT perform any validation that would
286 278
 		//  reject the message if an invalid tag key name is used."
287 279
 		if validateTagName(tagName) {
288
-			// "Tag values MUST be encoded as UTF8."
289
-			if !utf8.ValidString(tagValue) {
280
+			if !validateTagValue(tagValue) {
290 281
 				return ErrorInvalidTagContent
291 282
 			}
292 283
 			ircmsg.SetTag(tagName, UnescapeTagValue(tagValue))
@@ -356,10 +347,14 @@ func (ircmsg *IRCMessage) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagD
356 347
 	// write the tags, computing the budgets for client-only tags and regular tags
357 348
 	var lenRegularTags, lenClientOnlyTags, lenTags int
358 349
 	if 0 < len(ircmsg.tags) || 0 < len(ircmsg.clientOnlyTags) {
350
+		var tagError error
359 351
 		buf.WriteByte('@')
360 352
 		firstTag := true
361 353
 		writeTags := func(tags map[string]string) {
362 354
 			for tag, val := range tags {
355
+				if !(validateTagName(tag) && validateTagValue(val)) {
356
+					tagError = ErrorInvalidTagContent
357
+				}
363 358
 				if !firstTag {
364 359
 					buf.WriteByte(';') // delimiter
365 360
 				}
@@ -380,6 +375,9 @@ func (ircmsg *IRCMessage) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagD
380 375
 			lenClientOnlyTags -= 1
381 376
 		}
382 377
 		buf.WriteByte(' ')
378
+		if tagError != nil {
379
+			return nil, tagError
380
+		}
383 381
 	}
384 382
 	lenTags = buf.Len()
385 383
 

+ 10
- 1
vendor/github.com/goshuirc/irc-go/ircmsg/tags.go View File

@@ -3,7 +3,10 @@
3 3
 
4 4
 package ircmsg
5 5
 
6
-import "strings"
6
+import (
7
+	"strings"
8
+	"unicode/utf8"
9
+)
7 10
 
8 11
 var (
9 12
 	// valtoescape replaces real characters with message tag escapes.
@@ -73,6 +76,7 @@ func UnescapeTagValue(inString string) string {
73 76
 	return buf.String()
74 77
 }
75 78
 
79
+// https://ircv3.net/specs/extensions/message-tags.html#rules-for-naming-message-tags
76 80
 func validateTagName(name string) bool {
77 81
 	if len(name) == 0 {
78 82
 		return false
@@ -92,3 +96,8 @@ func validateTagName(name string) bool {
92 96
 	}
93 97
 	return true
94 98
 }
99
+
100
+// "Tag values MUST be encoded as UTF8."
101
+func validateTagValue(value string) bool {
102
+	return utf8.ValidString(value)
103
+}

+ 1
- 1
vendor/modules.txt View File

@@ -21,7 +21,7 @@ github.com/go-sql-driver/mysql
21 21
 # github.com/gorilla/websocket v1.4.2
22 22
 ## explicit
23 23
 github.com/gorilla/websocket
24
-# github.com/goshuirc/irc-go v0.0.0-20210222010959-6e139f6c42e9
24
+# github.com/goshuirc/irc-go v0.0.0-20210223005429-8d38e43fc6ed
25 25
 ## explicit
26 26
 github.com/goshuirc/irc-go/ircfmt
27 27
 github.com/goshuirc/irc-go/ircmsg

Loading…
Cancel
Save