mirror of
https://dev.narayana.im/narayana/telegabber.git
synced 2026-08-05 04:07:07 +00:00
Disallow non-BMP characters in occupant nicknames
This commit is contained in:
parent
7c9ea42f99
commit
b33cc3c75c
1 changed files with 11 additions and 0 deletions
|
|
@ -70,6 +70,8 @@ var replyRegex = regexp.MustCompile("\\A>>? ?([0-9]+)\\n")
|
|||
const newlineChar string = "\n"
|
||||
const messageHeaderSeparator string = " | " // no hrunicode allowed here yet
|
||||
|
||||
var bmpCeil = rune(0x0000ffff)
|
||||
|
||||
// ChatType is an enum of chat types, roughly corresponding to TDLib's one but better
|
||||
type ChatType int
|
||||
|
||||
|
|
@ -859,6 +861,15 @@ func (c *Client) GetMUCNickname(chatID int64) string {
|
|||
}
|
||||
fc := c.FormatContact(chatID)
|
||||
rp, err := gateway.ResourcePrep(fc)
|
||||
if err == nil {
|
||||
// additionally check for non-BMP characters
|
||||
for _, r := range rp {
|
||||
if r > bmpCeil {
|
||||
err = errors.New("Non-BMP character")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
log.Warnf("Resourceprep for %v failed, falling back to chat ID", fc)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue