diff options
| author | tjpcc <tjp@ctrl-c.club> | 2023-10-10 14:49:08 -0600 |
|---|---|---|
| committer | tjpcc <tjp@ctrl-c.club> | 2023-10-10 16:51:24 -0600 |
| commit | 38a195c6e62dfebed3c0c642ec9e3fcc89516097 (patch) | |
| tree | 699dd50488c8bf948ddc8d16757eeee619a884f5 /parse.go | |
| parent | 7efb04b5d7b5c5363a8a0d95fce5513cd125ede9 (diff) | |
"cmd" modifier to override CGI executable
fixes #6
Diffstat (limited to 'parse.go')
| -rw-r--r-- | parse.go | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -293,6 +293,10 @@ func validateRoute(serverType string, dir *RouteDirective) error { return fmt.Errorf("titan modifier only allowed on gemini{static}") } + if dir.Modifiers.ExecCmd != "" && !(dir.Type == "cgi" || (dir.Type == "static" && dir.Modifiers.Exec)) { + return fmt.Errorf("'cmd' modifier only valid on 'cgi' and 'static...with exec' directives") + } + return nil } @@ -410,6 +414,21 @@ func parseModifiers(text string) (Modifiers, string, error) { mod.DirList = true case "exec": mod.Exec = true + case "cmd": + if sep != " " { + return mod, "", errors.New("invalid 'cmd' clause") + } + text = strings.TrimLeft(text, " \t") + idx = strings.IndexAny(text, " \t,") + if idx == 0 { + return mod, "", errors.New("invalid 'cmd' clause") + } else if idx < 0 { + mod.ExecCmd = text + text = "" + } else { + mod.ExecCmd = text[0:idx] + text = text[idx+1:] + } case "extendedgophermap": mod.ExtendedGophermap = true case "autoatom": |
