mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-04-26 04:23:10 +00:00
Auth: Do not load users with weird characters in names
If they were registered in earlier versions, you should do something about it: * Delete them manually. * Workaround: register a new user to force user storage dump. You can delete them afterwards.
This commit is contained in:
parent
c1ac0bbd16
commit
2e59f75647
@ -50,6 +50,9 @@ func usersFromFile() []*User {
|
|||||||
|
|
||||||
func rememberUsers(userList []*User) {
|
func rememberUsers(userList []*User) {
|
||||||
for _, user := range userList {
|
for _, user := range userList {
|
||||||
|
if !IsValidUsername(user.Name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
users.Store(user.Name, user)
|
users.Store(user.Name, user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -136,7 +135,6 @@ func (user *User) ShowLockMaybe(w http.ResponseWriter, rq *http.Request) bool {
|
|||||||
|
|
||||||
// IsValidUsername checks if the given username is valid.
|
// IsValidUsername checks if the given username is valid.
|
||||||
func IsValidUsername(username string) bool {
|
func IsValidUsername(username string) bool {
|
||||||
fmt.Println("Is", username, "ok")
|
|
||||||
for _, r := range username {
|
for _, r := range username {
|
||||||
if strings.ContainsRune("?!:#@><*|\"'&%{}/", r) {
|
if strings.ContainsRune("?!:#@><*|\"'&%{}/", r) {
|
||||||
return false
|
return false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user