aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/api/api0/api.go4
-rw-r--r--pkg/api/api0/server.go8
2 files changed, 10 insertions, 2 deletions
diff --git a/pkg/api/api0/api.go b/pkg/api/api0/api.go
index 0786463..818f6b9 100644
--- a/pkg/api/api0/api.go
+++ b/pkg/api/api0/api.go
@@ -43,6 +43,10 @@ type Handler struct {
// usernames). If not provided, usernames will not be updated.
OriginAuthMgr *origin.AuthMgr
+ // CleanBadWords is used to filter bad words from server names and
+ // descriptions. If not provided, words will not be filtered.
+ CleanBadWords func(s string) string
+
// MainMenuPromos gets the main menu promos to return for a request.
MainMenuPromos func(*http.Request) MainMenuPromos
diff --git a/pkg/api/api0/server.go b/pkg/api/api0/server.go
index bb25790..06f4957 100644
--- a/pkg/api/api0/server.go
+++ b/pkg/api/api0/server.go
@@ -194,7 +194,9 @@ func (h *Handler) handleServerUpsert(w http.ResponseWriter, r *http.Request) {
return
}
} else {
- // TODO: bad word censoring
+ if h.CleanBadWords != nil {
+ v = h.CleanBadWords(v)
+ }
if n := 256; len(v) > n { // NorthstarLauncher@v1.9.7 limits it to 63
v = v[:n]
}
@@ -207,7 +209,9 @@ func (h *Handler) handleServerUpsert(w http.ResponseWriter, r *http.Request) {
}
if v := r.URL.Query().Get("description"); v != "" {
- // TODO: bad word censoring
+ if h.CleanBadWords != nil {
+ v = h.CleanBadWords(v)
+ }
if n := 1024; len(v) > n { // NorthstarLauncher@v1.9.7 doesn't have a limit
v = v[:n]
}