akosut      96/08/08 10:01:16

  Modified:    src       util_script.c
  Log:
  Fix problems with SCRIPT_NAME and PATH_INFO when "special" sorts of
  URL-to-filename mapping occurs.
  
  Reviewed by: Robert S. Thau, Ben Laurie
  
  Revision  Changes    Path
  1.20      +22 -7     apache/src/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/util_script.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -C3 -r1.19 -r1.20
  *** util_script.c     1996/08/06 19:31:06     1.19
  --- util_script.c     1996/08/08 17:01:15     1.20
  ***************
  *** 193,198 ****
  --- 193,215 ----
        }
    }
    
  + /* This "cute" little function comes about because the path info on
  +  * filenames and URLs aren't always the same. So we take the two,
  +  * and find as much of the two that match as possible.
  +  */
  + 
  + static int find_path_info (char *uri, char *path_info)
  + {
  +     int lu = strlen(uri);
  +     int lp = strlen(path_info);
  + 
  +     while (lu-- && lp-- && uri[lu] == path_info[lp]);
  + 
  +     while (uri[lu] != '\0' && uri[lu] != '/')
  +     lu++;
  + 
  +     return lu;
  + }
    
    void add_cgi_vars(request_rec *r)
    {
  ***************
  *** 212,222 ****
        if (!r->path_info || !*r->path_info || !strcmp (r->protocol, 
"INCLUDED")) {
            table_set (e, "SCRIPT_NAME", r->uri);
        } else {
  !         int path_info_start = strlen (r->uri) - strlen (r->path_info);
  !     
  !     r->uri[path_info_start] = '\0';
  !     table_set (e, "SCRIPT_NAME", r->uri);
  !     r->uri[path_info_start] = '/';
        }
        
        if (r->path_info && r->path_info[0]) {
  --- 229,239 ----
        if (!r->path_info || !*r->path_info || !strcmp (r->protocol, 
"INCLUDED")) {
            table_set (e, "SCRIPT_NAME", r->uri);
        } else {
  !     int path_info_start = find_path_info (r->uri, r->path_info);
  ! 
  !     table_set (e, "SCRIPT_NAME", pstrndup(r->pool, r->uri,
  !                                           path_info_start));
  !     table_set (e, "PATH_INFO", r->uri + path_info_start);
        }
        
        if (r->path_info && r->path_info[0]) {
  ***************
  *** 228,235 ****
        request_rec *pa_req = sub_req_lookup_uri(
                                    escape_uri(r->pool, r->path_info), r);
          
  -         table_set (e, "PATH_INFO", r->path_info);
  - 
        /* Don't bother destroying pa_req --- it's only created in
         * child processes which are about to jettison their address
         * space anyway.  BTW, we concatenate filename and path_info
  --- 245,250 ----
  
  
  

Reply via email to