fix: 目录搜索转义 LIKE 通配符并拒绝编号 inline
This commit is contained in:
@@ -171,6 +171,9 @@ func (h *RegisterHandler) register(ctx context.Context, req *protocol.RegisterRe
|
||||
}
|
||||
return RegisterResult{}, apiErr(http.StatusBadRequest, code, msg)
|
||||
}
|
||||
if strings.EqualFold(req.ID, "inline") {
|
||||
return RegisterResult{}, apiErr(http.StatusBadRequest, protocol.CodeBadRequest, "id reserved")
|
||||
}
|
||||
|
||||
id := req.ID
|
||||
loginPassword := req.LoginPassword
|
||||
|
||||
@@ -539,6 +539,18 @@ func TestRegister_LogOmitsSecrets(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegister_ReservedInlineID(t *testing.T) {
|
||||
env := openTestEnv(t)
|
||||
env.setRegistration(t, true, "inline-code1")
|
||||
code, resp, _ := env.doRegister(t, `{"registration_code":"inline-code1","id":"inline","login_password":"password1"}`)
|
||||
if code != http.StatusBadRequest || resp.Error == nil || resp.Error.Code != protocol.CodeBadRequest {
|
||||
t.Fatalf("status=%d resp=%+v", code, resp)
|
||||
}
|
||||
if _, _, ok := env.getEndpoint(t, "inline"); ok {
|
||||
t.Fatal("inline must not be created")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegister_NSTPasswordRejected(t *testing.T) {
|
||||
env := openTestEnv(t)
|
||||
env.setRegistration(t, true, "nst-code-01")
|
||||
|
||||
Reference in New Issue
Block a user