carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package rootparticipation
2
3import (
4 "github.com/carlosframework/platform/internal/controlname"
5 "strings"
6)
7
8func (q ExecutionRequest) Valid() bool {
9 if q.Schema != 1 || !validID(q.ID) || len(q.ID) > 128 || !controlname.ValidHostShape(q.Host) || !validID(q.Incarnation) || (q.Stamp == 0 && (q.Session != 0 || !validID(q.Op))) {
10 return false
11 }
12 if q.Operation == "executionView" && q.Token == "" {
13 return q.Op == "" || validID(q.Op)
14 }
15 if !validID(q.Op) {
16 return false
17 }
18 switch q.Operation {
19 case "executionBegin":
20 return q.Token == ""
21 case "executionRenew", "executionSettle", "executionView":
22 return validID(q.Token)
23 }
24 return false
25}
26
27func validID(s string) bool {
28 return s != "" && s != "." && s != ".." && !strings.ContainsAny(s, "/\\\x00\r\n\t ")
29}
30