From 2d8f749e361eeca5da698138a42e182fdfea4713 Mon Sep 17 00:00:00 2001 From: Qais Patankar Date: Sat, 25 Apr 2020 13:22:22 +0100 Subject: Fix #1120: replaceAction "_" crash (discord) (#1121) --- bridge/discord/helpers.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bridge/discord/helpers.go b/bridge/discord/helpers.go index 00592f3a..e183165c 100644 --- a/bridge/discord/helpers.go +++ b/bridge/discord/helpers.go @@ -188,8 +188,9 @@ func replaceEmotes(text string) string { } func (b *Bdiscord) replaceAction(text string) (string, bool) { - if strings.HasPrefix(text, "_") && strings.HasSuffix(text, "_") { - return text[1 : len(text)-1], true + length := len(text) + if length > 1 && text[0] == '_' && text[length-1] == '_' { + return text[1 : length-1], true } return text, false } -- cgit v1.2.3