fix regex matching protocol messages in the middle of multi-line public messages

This commit is contained in:
mappu 2017-11-14 18:36:34 +13:00
parent 5bf30ed95f
commit 2cbc8f8496

View File

@ -23,10 +23,13 @@ var rx_userCommand *regexp.Regexp
var ErrNotConnected error = errors.New("Not connected")
func init() {
rx_protocolMessage = regexp.MustCompile("(?ms)^[^|]*\\|")
rx_publicChat = regexp.MustCompile("(?ms)^<([^>]*)> (.*)$")
rx_incomingTo = regexp.MustCompile("(?ms)^([^ ]+) From: ([^ ]+) \\$<([^>]*)> (.*)")
rx_userCommand = regexp.MustCompile(`(?ms)^(\d+) (\d+)\s?([^\$]*)\$?(.*)`)
// With the `m` flag, use \A instead of ^ to anchor to start
// This fixes accidentally finding a better match in the middle of a multi-line message
rx_protocolMessage = regexp.MustCompile(`(?ms)\A[^|]*\|`)
rx_publicChat = regexp.MustCompile(`(?ms)\A<([^>]*)> (.*)$`)
rx_incomingTo = regexp.MustCompile(`(?ms)\A([^ ]+) From: ([^ ]+) \$<([^>]*)> (.*)`)
rx_userCommand = regexp.MustCompile(`(?ms)\A(\d+) (\d+)\s?([^\$]*)\$?(.*)`)
}
func Unescape(encoded string) string {