From: Adam Chlipala Date: Fri, 15 Dec 2006 19:34:17 +0000 (+0000) Subject: Fix problem noted by omry on original domtool; namely, bad handling of rewrites insid... X-Git-Tag: release_2010-11-19~301 X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/commitdiff_plain/ce01b51a0ad907253957a8ca9419cf2fbd42af91?hp=bbdf617f34ebca729e1188ef666a9ba9ef004773 Fix problem noted by omry on original domtool; namely, bad handling of rewrites inside local scopes --- diff --git a/src/plugins/apache.sml b/src/plugins/apache.sml index 24b424e..91209af 100644 --- a/src/plugins/apache.sml +++ b/src/plugins/apache.sml @@ -29,6 +29,10 @@ val _ = Env.type_one "web_node" orelse (Domain.hasPriv "www" andalso List.exists (fn x => x = node) Config.Apache.webNodes_admin)) +val _ = Env.registerFunction ("web_node_to_node", + fn [e] => SOME e + | _ => NONE) + val _ = Env.type_one "proxy_port" Env.int (fn n => n > 1024) @@ -68,10 +72,6 @@ val _ = Env.type_one "location" val dl = ErrorMsg.dummyLoc -val _ = Env.registerFunction ("web_node_to_node", - fn [e] => SOME e - | _ => NONE) - val _ = Defaults.registerDefault ("WebNodes", (TList (TBase "web_node", dl), dl), (fn () => (EList (map (fn s => (EString s, dl)) Config.Apache.webNodes_default), dl))) @@ -272,6 +272,7 @@ fun write' s = app (fn (node, file) => TextIO.output (file, s node)) (!vhostFile fun write s = app (fn (_, file) => TextIO.output (file, s)) (!vhostFiles) val rewriteEnabled = ref false +val localRewriteEnabled = ref false val currentVhost = ref "" val currentVhostId = ref "" @@ -319,6 +320,7 @@ val () = Env.containerV_one "vhost" currentVhostId := vhostId; rewriteEnabled := false; + localRewriteEnabled := false; vhostFiles := map (fn node => let val file = Domain.domainFile {node = node, @@ -370,24 +372,38 @@ val () = Env.containerV_one "vhost" write "\n"; app (TextIO.closeOut o #2) (!vhostFiles))) +val inLocal = ref false + val () = Env.container_one "location" ("prefix", Env.string) (fn prefix => (write "\t\n"), - fn () => write "\t\n") + write ">\n"; + inLocal := true), + fn () => (write "\t\n"; + inLocal := false; + localRewriteEnabled := false)) val () = Env.container_one "directory" ("directory", Env.string) (fn directory => (write "\t\n"), - fn () => write "\t\n") + write ">\n"; + inLocal := true), + fn () => (write "\t\n"; + inLocal := false; + localRewriteEnabled := false)) fun checkRewrite () = - if !rewriteEnabled then + if !inLocal then + if !rewriteEnabled orelse !localRewriteEnabled then + () + else + (write "\tRewriteEngine on\n"; + localRewriteEnabled := true) + else if !rewriteEnabled then () else (write "\tRewriteEngine on\n";