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