Ticket #536: lighttpd.ssi.patch

File lighttpd.ssi.patch, 1.8 kB (added by dhazeghi, 2 years ago)

updated patch for lighttpd 1.4.11

  • mod_ssi.c

    old new  
    286286        return 0; 
    287287} 
    288288 
     289URIHANDLER_FUNC(mod_ssi_physical_path); 
     290 
    289291static int process_ssi_stmt(server *srv, connection *con, plugin_data *p,  
    290292                            const char **l, size_t n) { 
    291293        size_t i, ssicmd = 0; 
     
    546548                } 
    547549                 
    548550                if (0 == stat(p->stat_fn->ptr, &st)) { 
     551                        buffer *tmp; 
    549552                        time_t t = st.st_mtime; 
    550553                         
    551554                        switch (ssicmd) { 
     
    574577                                } 
    575578                                break; 
    576579                        case SSI_INCLUDE: 
    577                                 chunkqueue_append_file(con->write_queue, p->stat_fn, 0, st.st_size); 
    578                                 break; 
     580                                /* do recursive SSI expansion */ 
     581                                 
     582                                /* prevents infinite loop */ 
     583                                if (con->loops_per_request > 25 || buffer_is_equal(con->physical.path, p->stat_fn)) { 
     584                                        buffer_copy_string(srv->tmp_buf, "<!-- your include directives create an infinite loop; aborting -->"); 
     585                                        chunkqueue_append_buffer(con->write_queue, srv->tmp_buf); 
     586                                        break; 
     587                                } 
     588 
     589                                tmp = buffer_init(); 
     590                                buffer_copy_string_buffer(tmp, con->physical.path); /* save path of current document */ 
     591                                buffer_copy_string_buffer(con->physical.path, p->stat_fn); /* next sub-document to parse */ 
     592                                if (mod_ssi_physical_path(srv,con,p) != HANDLER_FINISHED) { 
     593                                        /* the document was not processed, so write it as is */ 
     594                                        chunkqueue_append_file(con->write_queue, con->physical.path, 0, st.st_size); 
     595                                } 
     596                                buffer_copy_string_buffer(con->physical.path, tmp); /* restore saved path */ 
     597                                buffer_free(tmp); 
     598                        break; 
    579599                        } 
    580600                } else { 
    581601                        log_error_write(srv, __FILE__, __LINE__, "sbs", 
     
    10441064         
    10451065        if (con->physical.path->used == 0) return HANDLER_GO_ON; 
    10461066         
     1067        con->loops_per_request++; 
     1068         
    10471069        mod_ssi_patch_connection(srv, con, p); 
    10481070         
    10491071        for (k = 0; k < p->conf.ssi_extension->used; k++) {