The following patch allow for recursion in SSI include directive (up to 25 in depth):
--- mod_ssi.c.dist 2006-02-10 13:33:00.000000000 -0500
+++ mod_ssi.c 2006-02-20 10:01:00.000000000 -0500
@@ -576,7 +576,24 @@
}
break;
case SSI_INCLUDE:
- chunkqueue_append_file(con->write_queue, p->stat_fn, 0, st.st_size);
+ // do recursive SSI expansion
+
+ // prevents infinite loop
+ if (con->loops_per_request > 25 || buffer_is_equal(con->physical.path, p->stat_fn)) {
+ buffer_copy_string(srv->tmp_buf, "<!-- your include directives create an infinite loop;
aborting -->");
+ chunkqueue_append_buffer(con->write_queue, srv->tmp_buf);
+ break;
+ }
+
+ tmp = buffer_init();
+ buffer_copy_string_buffer(tmp, con->physical.path); // save path of current document
+ buffer_copy_string_buffer(con->physical.path, p->stat_fn); // next sub-document to parse
+ if (mod_ssi_physical_path(srv,con,p) != HANDLER_FINISHED) {
+ // the document was not processed, so write it as is
+ chunkqueue_append_file(con->write_queue, con->physical.path, 0, st.st_size);
+ }
+ buffer_copy_string_buffer(con->physical.path, tmp); // restore saved path
+ buffer_free(tmp);
break;
}
} else {
@@ -1046,6 +1063,8 @@
if (con->physical.path->used == 0) return HANDLER_GO_ON;
+ con->loops_per_request++;
+
mod_ssi_patch_connection(srv, con, p);
for (k = 0; k < p->conf.ssi_extension->used; k++) {