Add cgiExtension
authoradamch <adamch>
Sat, 15 Dec 2007 01:13:21 +0000 (01:13 +0000)
committeradamch <adamch>
Sat, 15 Dec 2007 01:13:21 +0000 (01:13 +0000)
lib/apache_options.dtl
src/plugins/apache.sml

index a40105d..7becc15 100644 (file)
@@ -32,3 +32,7 @@ extern val action : no_spaces -> location -> [^Vhost];
 extern val addDefaultCharset : no_spaces -> [^Vhost];
 {{See <a href="http://httpd.apache.org/docs/2.0/mod/core.html#adddefaultcharset">the
   Apache documentation</a>.}}
+
+extern type file_extension;
+extern val cgiExtension : file_extension -> [^Vhost];
+{{Ask for all files ending in a particular extension to be executed as CGI.}}
index e81792a..617420a 100644 (file)
@@ -111,6 +111,15 @@ fun ssl e = case e of
              | (EApp ((EVar "use_cert", _), s), _) => Option.map SOME (Env.string s)
              | _ => NONE
 
+fun validExtension s =
+    size s > 0
+    andalso size s < 20
+    andalso CharVector.all (fn ch => Char.isAlphaNum ch orelse ch = #"_") s
+
+val _ = Env.type_one "file_extension"
+       Env.string
+       validExtension
+
 val defaults = [("WebPlaces",
                 (TList (TBase "web_place", dl), dl),
                 (fn () => (EList (map webPlaceDefault Config.Apache.webNodes_default), dl))),
@@ -706,6 +715,12 @@ val () = Env.action_one "unset_options"
                       app (fn opt => (write " -"; write opt)) opts;
                       write "\n"))
 
+val () = Env.action_one "cgiExtension"
+        ("extension", Env.string)
+        (fn ext => (write "\tAddHandler cgi-script ";
+                    write ext;
+                    write "\n"))
+
 val () = Env.action_one "directoryIndex"
         ("filenames", Env.list Env.string)
         (fn opts =>