6
1
mirror of https://git.mills.io/saltyim/saltyim.git synced 2024-06-16 11:58:24 +00:00

Fix PackMessage to ensure every message ends with a UNIX newline (\n)

This commit is contained in:
James Mills 2022-03-23 23:25:03 +10:00
parent 5ac634e696
commit 5dccf640f2

@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"strings"
"time"
"git.mills.io/prologic/msgbus"
@ -22,7 +23,7 @@ type configCache map[string]Config
// PackMessage formts an outoing message in the Message Format
// <timestamp>\t(<sender>) <message>
func PackMessage(me *Addr, msg string) []byte {
return []byte(fmt.Sprint(time.Now().UTC().Format(time.RFC3339), "\t", me.Formatted(), "\t", msg))
return []byte(fmt.Sprint(time.Now().UTC().Format(time.RFC3339), "\t", me.Formatted(), "\t", strings.TrimSpace(msg), "\n"))
}
// Send sends the encrypted message `msg` to the Endpoint `endpoint` using a