summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-06-15 00:07:12 +0200
committerWim <wim@42.be>2017-06-15 00:07:12 +0200
commit8a55c97b4e2c49e0bb762184f6a546ffbb891e77 (patch)
treeebe535d2f1d111c5f238c63c62740cc5c07ae10d
parent9e34162a09c8cd9a49ce8a8db6f498a784aba9fc (diff)
downloadmatterbridge-msglm-8a55c97b4e2c49e0bb762184f6a546ffbb891e77.tar.gz
matterbridge-msglm-8a55c97b4e2c49e0bb762184f6a546ffbb891e77.tar.bz2
matterbridge-msglm-8a55c97b4e2c49e0bb762184f6a546ffbb891e77.zip
Fix utf-8 issues #193
-rw-r--r--gateway/gateway.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 022f606f..881e0ac9 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -235,7 +235,16 @@ func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) {
nick = dest.Config.RemoteNickFormat
}
if len(msg.Username) > 0 {
- nick = strings.Replace(nick, "{NOPINGNICK}", msg.Username[:1]+"​"+msg.Username[1:], -1)
+ // fix utf-8 issue #193
+ i := 0
+ for index := range msg.Username {
+ if i == 1 {
+ i = index
+ break
+ }
+ i++
+ }
+ nick = strings.Replace(nick, "{NOPINGNICK}", msg.Username[:i]+"​"+msg.Username[i:], -1)
}
nick = strings.Replace(nick, "{NICK}", msg.Username, -1)
nick = strings.Replace(nick, "{BRIDGE}", br.Name, -1)