src/server/util/util.c

changeset 627
b30bf356dac4
parent 584
f3ddd6dc8e7b
child 653
c4dae65155e9
equal deleted inserted replaced
626:c5ee5c4f8f03 627:b30bf356dac4
351 int rv = 1; 351 int rv = 1;
352 352
353 for(t = s, u = s; *t; ++t, ++u) { 353 for(t = s, u = s; *t; ++t, ++u) {
354 if (*t == '%') { 354 if (*t == '%') {
355 t1 = t[1] & 0xdf; /* [a-f] -> [A-F] */ 355 t1 = t[1] & 0xdf; /* [a-f] -> [A-F] */
356 if ((t1 < 'A' || t1 > 'F') && (t[1] < '0' || t[1] > '9')) 356 if ((t1 < 'A' || t1 > 'F') && (t[1] < '0' || t[1] > '9')) {
357 rv = 0; 357 return 0;
358 }
358 359
359 t2 = t[2] & 0xdf; /* [a-f] -> [A-F] */ 360 t2 = t[2] & 0xdf; /* [a-f] -> [A-F] */
360 if ((t2 < 'A' || t2 > 'F') && (t[2] < '0' || t[2] > '9')) 361 if ((t2 < 'A' || t2 > 'F') && (t[2] < '0' || t[2] > '9')) {
361 rv = 0; 362 return 0;
363 }
362 364
363 *u = ((t[1] >= 'A' ? ((t[1] & 0xdf) - 'A')+10 : (t[1] - '0'))*16) + 365 *u = ((t[1] >= 'A' ? ((t[1] & 0xdf) - 'A')+10 : (t[1] - '0'))*16) +
364 (t[2] >= 'A' ? ((t[2] & 0xdf) - 'A')+10 : (t[2] - '0')); 366 (t[2] >= 'A' ? ((t[2] & 0xdf) - 'A')+10 : (t[2] - '0'));
365 t += 2; 367 t += 2;
366 } 368 }
367 else if (u != t) 369 else if (u != t)
368 *u = *t; 370 *u = *t;
369 } 371 }
370 *u = *t; 372 *u = *t;
371 373
372 return rv; 374 return 1;
373 } 375 }
374 376
375 377
376 NSAPI_PUBLIC int 378 NSAPI_PUBLIC int
377 util_uri_unescape_plus (const char *src, char *trg, int len) 379 util_uri_unescape_plus (const char *src, char *trg, int len)

mercurial