comparison src/c/request.c @ 1371:4e5ca2a77a4d

Fix time comparison operators; safer saving of queryStrings
author Adam Chlipala <adam@chlipala.net>
date Mon, 27 Dec 2010 12:08:00 -0500
parents 44a12a321150
children 76514ddf3a97
comparison
equal deleted inserted replaced
1370:44a12a321150 1371:4e5ca2a77a4d
168 char *path_copy, *queryString; 168 char *path_copy, *queryString;
169 } *uw_request_context; 169 } *uw_request_context;
170 170
171 uw_request_context uw_new_request_context(void) { 171 uw_request_context uw_new_request_context(void) {
172 uw_request_context r = malloc(sizeof(struct uw_rc)); 172 uw_request_context r = malloc(sizeof(struct uw_rc));
173 r->path_copy_size = r->queryString_size = 0; 173 r->path_copy_size = 0;
174 r->queryString_size = 1;
174 r->path_copy = malloc(0); 175 r->path_copy = malloc(0);
175 r->queryString = malloc(0); 176 r->queryString = malloc(1);
176 return r; 177 return r;
177 } 178 }
178 179
179 void uw_free_request_context(uw_request_context r) { 180 void uw_free_request_context(uw_request_context r) {
180 free(r->path_copy); 181 free(r->path_copy);
199 const char *prefix = uw_get_url_prefix(ctx); 200 const char *prefix = uw_get_url_prefix(ctx);
200 char *s; 201 char *s;
201 int had_error = 0; 202 int had_error = 0;
202 char errmsg[ERROR_BUF_LEN]; 203 char errmsg[ERROR_BUF_LEN];
203 204
205 rc->queryString[0] = 0;
206
204 for (s = path; *s; ++s) { 207 for (s = path; *s; ++s) {
205 if (s[0] == '%' && s[1] == '2' && s[2] == '7') { 208 if (s[0] == '%' && s[1] == '2' && s[2] == '7') {
206 s[0] = '\''; 209 s[0] = '\'';
207 memmove(s+1, s+3, strlen(s+3)+1); 210 memmove(s+1, s+3, strlen(s+3)+1);
208 } 211 }
387 if (len+1 > rc->queryString_size) { 390 if (len+1 > rc->queryString_size) {
388 rc->queryString_size = len+1; 391 rc->queryString_size = len+1;
389 rc->queryString = realloc(rc->queryString, len+1); 392 rc->queryString = realloc(rc->queryString, len+1);
390 } 393 }
391 strcpy(rc->queryString, inputs); 394 strcpy(rc->queryString, inputs);
392 uw_setQueryString(ctx, rc->queryString);
393 395
394 while (*inputs) { 396 while (*inputs) {
395 name = inputs; 397 name = inputs;
396 if ((inputs = strchr(inputs, '&'))) 398 if ((inputs = strchr(inputs, '&')))
397 *inputs++ = 0; 399 *inputs++ = 0;
414 } 416 }
415 417
416 log_debug(logger_data, "Serving URI %s....\n", path); 418 log_debug(logger_data, "Serving URI %s....\n", path);
417 419
418 while (1) { 420 while (1) {
421 uw_setQueryString(ctx, rc->queryString);
422
419 if (!had_error) { 423 if (!had_error) {
420 size_t path_len = strlen(path); 424 size_t path_len = strlen(path);
421 425
422 on_success(ctx); 426 on_success(ctx);
423 427