/[jscoverage]/trunk/jscoverage-server.c
ViewVC logotype

Diff of /trunk/jscoverage-server.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 241 by siliconforks, Fri Oct 3 23:52:10 2008 UTC revision 253 by siliconforks, Sun Oct 5 18:09:02 2008 UTC
# Line 242  Line 242 
242      return c - '0';      return c - '0';
243    }    }
244    else if ('A' <= c && c <= 'F') {    else if ('A' <= c && c <= 'F') {
245      return c - 'A';      return c - 'A' + 10;
246    }    }
247    else if ('a' <= c && c <= 'f') {    else if ('a' <= c && c <= 'f') {
248      return c - 'a';      return c - 'a' + 10;
249    }    }
250    else {    else {
251      return 0;      return 0;
# Line 933  Line 933 
933    /* add the `Server' response-header (RFC 2616 14.38, 3.8) */    /* add the `Server' response-header (RFC 2616 14.38, 3.8) */
934    HTTPExchange_add_response_header(exchange, HTTP_SERVER, "jscoverage-server/" VERSION);    HTTPExchange_add_response_header(exchange, HTTP_SERVER, "jscoverage-server/" VERSION);
935    
936      char * decoded_path = NULL;
937    char * filesystem_path = NULL;    char * filesystem_path = NULL;
938    
939    const char * abs_path = HTTPExchange_get_abs_path(exchange);    const char * abs_path = HTTPExchange_get_abs_path(exchange);
940    assert(*abs_path != '\0');    assert(*abs_path != '\0');
941    
942    if (str_starts_with(abs_path, "/jscoverage")) {    decoded_path = decode_uri_component(abs_path);
943    
944      if (str_starts_with(decoded_path, "/jscoverage")) {
945      handle_jscoverage_request(exchange);      handle_jscoverage_request(exchange);
946      goto done;      goto done;
947    }    }
948    
949    if (strstr(abs_path, "..") != NULL) {    if (strstr(decoded_path, "..") != NULL) {
950      send_response(exchange, 403, "Forbidden\n");      send_response(exchange, 403, "Forbidden\n");
951      goto done;      goto done;
952    }    }
953    
954    filesystem_path = make_path(document_root, abs_path + 1);    filesystem_path = make_path(document_root, decoded_path + 1);
955    size_t filesystem_path_length = strlen(filesystem_path);    size_t filesystem_path_length = strlen(filesystem_path);
956    if (filesystem_path_length > 0 && filesystem_path[filesystem_path_length - 1] == '/') {    if (filesystem_path_length > 0 && filesystem_path[filesystem_path_length - 1] == '/') {
957      /* stat on Windows doesn't work with trailing slash */      /* stat on Windows doesn't work with trailing slash */
# Line 1052  Line 1055 
1055    
1056  done:  done:
1057    free(filesystem_path);    free(filesystem_path);
1058      free(decoded_path);
1059  }  }
1060    
1061  static void handler(HTTPExchange * exchange) {  static void handler(HTTPExchange * exchange) {

Legend:
Removed from v.241  
changed lines
  Added in v.253

  ViewVC Help
Powered by ViewVC 1.1.24