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>
This commit is contained in:
Manuel Rüger 2026-03-13 01:21:28 +01:00
parent 2a505a24a8
commit 566fd74efe

View File

@ -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{}{