mirror of
https://github.com/kovetskiy/mark.git
synced 2026-03-19 09:07:36 +08:00
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:
parent
2a505a24a8
commit
566fd74efe
@ -557,7 +557,10 @@ func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
if emojiString != "" {
|
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)
|
unicodeHex := fmt.Sprintf("%x", r)
|
||||||
|
|
||||||
properties["emoji-title-draft"] = map[string]interface{}{
|
properties["emoji-title-draft"] = map[string]interface{}{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user