From 566fd74efed4faca159780d2de5c86138e8859fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 13 Mar 2026 01:21:28 +0100 Subject: [PATCH] fix: validate emoji rune from utf8.DecodeRuneInString DecodeRuneInString returns utf8.RuneError for invalid UTF-8, which was silently converted to the hex string "fffd" and sent to Confluence. Return an error instead so the caller gets a clear diagnostic rather than storing a replacement character as the page emoji. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- confluence/api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/confluence/api.go b/confluence/api.go index b54ae97..40d11c8 100644 --- a/confluence/api.go +++ b/confluence/api.go @@ -557,7 +557,10 @@ func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, ve } if emojiString != "" { - r, _ := utf8.DecodeRuneInString(emojiString) + r, size := utf8.DecodeRuneInString(emojiString) + if r == utf8.RuneError && size <= 1 { + return fmt.Errorf("invalid UTF-8 in emoji: %q", emojiString) + } unicodeHex := fmt.Sprintf("%x", r) properties["emoji-title-draft"] = map[string]interface{}{