summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/channel/channel.go2
-rw-r--r--server/object/object.go2
-rw-r--r--server/user/user.go2
-rw-r--r--server/validate/validate.go49
4 files changed, 3 insertions, 52 deletions
diff --git a/server/channel/channel.go b/server/channel/channel.go
index c9620bf..e2a18c5 100644
--- a/server/channel/channel.go
+++ b/server/channel/channel.go
@@ -4,7 +4,7 @@ import (
"citrons.xyz/talk/proto"
"citrons.xyz/talk/server/object"
"citrons.xyz/talk/server/session"
- "citrons.xyz/talk/server/validate"
+ "citrons.xyz/talk/proto/validate"
"citrons.xyz/talk/server/user"
"strings"
"strconv"
diff --git a/server/object/object.go b/server/object/object.go
index cd7ba84..70b84c2 100644
--- a/server/object/object.go
+++ b/server/object/object.go
@@ -3,7 +3,7 @@ package object
import (
"citrons.xyz/talk/proto"
"citrons.xyz/talk/server/session"
- "citrons.xyz/talk/server/validate"
+ "citrons.xyz/talk/proto/validate"
"bufio"
"bytes"
"log"
diff --git a/server/user/user.go b/server/user/user.go
index d2d5724..198fc0f 100644
--- a/server/user/user.go
+++ b/server/user/user.go
@@ -3,8 +3,8 @@ package user
import (
"citrons.xyz/talk/server/object"
"citrons.xyz/talk/server/session"
- "citrons.xyz/talk/server/validate"
"citrons.xyz/talk/server/passwords"
+ "citrons.xyz/talk/proto/validate"
"citrons.xyz/talk/proto"
bolt "go.etcd.io/bbolt"
"log"
diff --git a/server/validate/validate.go b/server/validate/validate.go
deleted file mode 100644
index 7251895..0000000
--- a/server/validate/validate.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package validate
-
-import (
- "strings"
- "unicode"
-)
-
-func Name(name string) bool {
- if len(Fold(name)) == 0 || len(name) > 64 {
- return false
- }
- for _, r := range name {
- if unicode.IsControl(r) {
- return false
- }
- }
- return true
-}
-
-func Fold(s string) string {
- var sb strings.Builder
- var wasSpace bool
- for _, r := range s {
- for {
- f := unicode.SimpleFold(r)
- if f <= r {
- r = f
- break
- }
- r = f
- }
- r = unicode.ToLower(r)
-
- if !unicode.IsPrint(r) {
- continue
- }
-
- if r == ' ' {
- if wasSpace {
- continue
- }
- wasSpace = true
- } else {
- wasSpace = false
- }
- sb.WriteRune(r)
- }
- return strings.TrimSpace(sb.String())
-}