summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/parse.go b/parse.go
index 0fe3f30..d087e95 100644
--- a/parse.go
+++ b/parse.go
@@ -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":