Changeset 435
- Timestamp:
- 10/24/06 11:25:47 (2 years ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/buffer.c (modified) (1 diff)
- cherokee/trunk/cherokee/exts_table.c (modified) (2 diffs)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/util.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r434 r435 1 2006-10-24 A.D.F <adefacc@tin.it> 2 3 * cherokee/buffer.c (cherokee_buffer_decode): change 4 cherokee_buffer_decode() in order to speed up it and to avoid to 5 use original BSD (Jeff Poskanzer) source code. 6 7 2006-10-24 Alvaro Lopez Ortega <alvaro@alobbs.com> 8 9 * cherokee/util.h, cherokee/util.c (cherokee_hexit): Removed. 10 1 11 2006-10-21 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 12 cherokee/trunk/cherokee/buffer.c
r417 r435 351 351 352 352 353 /* 354 * Decode a string that may have encoded characters %xx 355 * where xx is the hexadecimal number corresponding 356 * to the character ascii value. 357 */ 353 358 ret_t 354 359 cherokee_buffer_decode (cherokee_buffer_t *buffer) 355 360 { 356 char *from; 357 char *to; 361 static const char hex2dec_tab[256] = { 362 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-0F */ 363 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10-1F */ 364 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20-2F */ 365 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 30-3F */ 366 0,10,11,12,13,14,15, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-4F */ 367 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50-5F */ 368 0,10,11,12,13,14,15, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60-6F */ 369 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70-7F */ 370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80-8F */ 371 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90-9F */ 372 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A0-AF */ 373 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* B0-BF */ 374 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* C0-CF */ 375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* D0-DF */ 376 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* E0-EF */ 377 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0-FF */ 378 }; 379 380 char *psrc; 381 char *ptgt; 382 int len; 383 384 #define hex2dec_m(c) ( (int) hex2dec_tab[ ( (unsigned char )(c) ) ] ) 358 385 359 386 if (buffer->buf == NULL) { 360 387 return ret_error; 361 388 } 362 363 /* Copies and decodes a string. It's ok for from and to to be 364 * the same string. 365 */ 366 from = to = buffer->buf; 367 368 for (; *from != '\0'; ++to, ++from) { 369 if (from[0] == '%' && isxdigit(from[1]) && isxdigit(from[2])) { 370 if (unlikely (((from[1] == '0') && (from[2] == '0')))) { 389 390 /* Verify if decoding is needed. 391 */ 392 if ((psrc = strchr (buffer->buf, '%')) == NULL) 393 return ret_ok; 394 395 /* Decode string. 396 */ 397 len = buffer->len; 398 for (ptgt = psrc; *psrc != '\0'; ++ptgt, ++psrc) { 399 if (psrc[0] == '%' && isxdigit(psrc[1]) && isxdigit(psrc[2])) { 400 if (unlikely (((psrc[1] == '0') && (psrc[2] == '0')))) { 371 401 /* Replace null bytes (%00) with 372 402 * spaces, to prevent attacks 373 403 */ 374 * to= ' ';404 *ptgt = ' '; 375 405 } else { 376 * to = cherokee_hexit(from[1]) * 16 + cherokee_hexit(from[2]);406 *ptgt = hex2dec_m(psrc[1]) * 16 + hex2dec_m(psrc[2]); 377 407 } 378 408 379 from+= 2;380 buffer->len-= 2;409 psrc += 2; 410 len -= 2; 381 411 } else { 382 * to = *from;412 *ptgt = *psrc; 383 413 } 384 414 } 385 *to = '\0'; 386 387 return ret_ok; 388 } 415 *ptgt = '\0'; 416 buffer->len = len; 417 418 #undef hex2dec_m 419 return ret_ok; 420 } 421 389 422 390 423 ret_t cherokee/trunk/cherokee/exts_table.c
r433 r435 62 62 if (dot == NULL) return ret_not_found; 63 63 64 printf ("GET0: et %p table %p ext %s\n", et, &et->table, dot+1);65 64 ret = cherokee_table_get (&et->table, dot+1, (void **)&entry); 66 printf ("GET1: et %p table %p ext %s: %d\n", et, &et->table, dot+1, ret);67 65 if (ret != ret_ok) return ret; 68 66 … … 93 91 * plugin entry object. 94 92 */ 95 printf("ADD: et %p table %p ext %s\n", et, &et->table, ext);93 TRACE ("ADD: et %p table %p ext %s\n", et, &et->table, ext); 96 94 return cherokee_table_add (&et->table, ext, plugin_entry); 97 95 } cherokee/trunk/cherokee/util.c
r427 r435 90 90 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; 91 91 const char *cherokee_weekdays[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; 92 93 94 95 int96 cherokee_hexit (char c)97 {98 if ( c >= '0' && c <= '9' )99 return c - '0';100 if ( c >= 'a' && c <= 'f' )101 return c - 'a' + 10;102 if ( c >= 'A' && c <= 'F' )103 return c - 'A' + 10;104 105 /* shouldn't happen, we're guarded by isxdigit() */106 return 0;107 }108 92 109 93 cherokee/trunk/cherokee/util.h
r426 r435 76 76 /* String management functions 77 77 */ 78 int cherokee_hexit (char c);79 78 int cherokee_isbigendian (void); 80 79 char *cherokee_min_str (char *s1, char *s2);