From 98235afe06ff58f56b6a2c0380637d44fca9617a Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Wed, 13 Jan 2021 23:00:48 +0100 Subject: [PATCH] Disallow unknown fields in group descriptions. Make the de-facto "comment" and "contact" fields official. --- README | 3 +++ group/group.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README b/README index 3d9c163..01b0aa3 100644 --- a/README +++ b/README @@ -224,6 +224,9 @@ the group. - `public`: if true, then the group is visible on the landing page; - `description`: a human-readable description of the group; this is displayed on the landing page for public groups; + - `contact`: a human-readable contact for this group, such as an e-mail + address; + - `comment`: a human-readable string; - `max-clients`: the maximum number of clients that may join the group at a time; - `max-history-age`: the time, in seconds, during which chat history is diff --git a/group/group.go b/group/group.go index 1a7b56b..15dcc92 100644 --- a/group/group.go +++ b/group/group.go @@ -659,6 +659,8 @@ type description struct { modTime time.Time `json:"-"` fileSize int64 `json:"-"` Description string `json:"description,omitempty"` + Contact string `json:"contact,omitempty"` + Comment string `json:"comment,omitempty"` Redirect string `json:"redirect,omitempty"` Public bool `json:"public,omitempty"` MaxClients int `json:"max-clients,omitempty"` @@ -744,6 +746,7 @@ func GetDescription(name string) (*description, error) { } d := json.NewDecoder(r) + d.DisallowUnknownFields() err = d.Decode(&desc) if err != nil { return nil, err