| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: fetch.c,v 1.13 2008/10/06 12:58:29 joerg Exp $ */ | | 1 | /* $NetBSD: fetch.c,v 1.14 2008/10/10 22:51:41 joerg Exp $ */ |
2 | /*- | | 2 | /*- |
3 | * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav | | 3 | * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav |
4 | * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org> | | 4 | * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer | | 11 | * notice, this list of conditions and the following disclaimer |
12 | * in this position and unchanged. | | 12 | * in this position and unchanged. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -500,27 +500,27 @@ quote_doc: | | | @@ -500,27 +500,27 @@ quote_doc: |
500 | | | 500 | |
501 | if ((u->doc = malloc(count)) == NULL) { | | 501 | if ((u->doc = malloc(count)) == NULL) { |
502 | fetch_syserr(); | | 502 | fetch_syserr(); |
503 | goto ouch; | | 503 | goto ouch; |
504 | } | | 504 | } |
505 | for (i = 0; *p != '\0'; ++p) { | | 505 | for (i = 0; *p != '\0'; ++p) { |
506 | if ((!pre_quoted && *p == '%') || | | 506 | if ((!pre_quoted && *p == '%') || |
507 | !fetch_urlpath_safe(*p)) { | | 507 | !fetch_urlpath_safe(*p)) { |
508 | u->doc[i++] = '%'; | | 508 | u->doc[i++] = '%'; |
509 | if ((unsigned char)*p < 160) | | 509 | if ((unsigned char)*p < 160) |
510 | u->doc[i++] = '0' + ((unsigned char)*p) / 16; | | 510 | u->doc[i++] = '0' + ((unsigned char)*p) / 16; |
511 | else | | 511 | else |
512 | u->doc[i++] = 'a' - 10 + ((unsigned char)*p) / 16; | | 512 | u->doc[i++] = 'a' - 10 + ((unsigned char)*p) / 16; |
513 | if ((unsigned char)*p % 16 < 16) | | 513 | if ((unsigned char)*p % 16 < 10) |
514 | u->doc[i++] = '0' + ((unsigned char)*p) % 16; | | 514 | u->doc[i++] = '0' + ((unsigned char)*p) % 16; |
515 | else | | 515 | else |
516 | u->doc[i++] = 'a' - 10 + ((unsigned char)*p) % 16; | | 516 | u->doc[i++] = 'a' - 10 + ((unsigned char)*p) % 16; |
517 | } else | | 517 | } else |
518 | u->doc[i++] = *p; | | 518 | u->doc[i++] = *p; |
519 | } | | 519 | } |
520 | u->doc[i] = '\0'; | | 520 | u->doc[i] = '\0'; |
521 | | | 521 | |
522 | return (u); | | 522 | return (u); |
523 | | | 523 | |
524 | ouch: | | 524 | ouch: |
525 | free(u); | | 525 | free(u); |
526 | return (NULL); | | 526 | return (NULL); |