dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 3caebb0e954b778432e5655b7541c68265e151c5
parent ff752d74bb0bd1ec62009e0049f09f454f7b39f6
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 12 Jan 2024 12:40:14 -0800

fix crash when quoting with invalid username position

Diffstat:
Mpkg/database/utils/processMessage.go | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/pkg/database/utils/processMessage.go b/pkg/database/utils/processMessage.go @@ -150,7 +150,12 @@ func convertQuote(db *database.DkfDB, origHtml string, roomKey string, roomID da suffixLen := len(quoteSuffix) if len(origHtml) > prefixLen+9 { hourMinSec := origHtml[prefixLen : prefixLen+8] - username := database.Username(origHtml[prefixLen+10 : strings.Index(origHtml[prefixLen+10:], " ")+prefixLen+10]) + usernameStartIdx := prefixLen + 10 + spaceIdx := strings.Index(origHtml[usernameStartIdx:], " ") + var username database.Username + if spaceIdx >= 3 { + username = database.Username(origHtml[usernameStartIdx : spaceIdx+usernameStartIdx]) + } if quoted = getQuotedChatMessage(db, hourMinSec, username, roomID); quoted != nil { html = GetQuoteTxt(db, roomKey, *quoted) html += origHtml[idx+suffixLen:]