X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Furl.c;h=6d940018d2165acbb27124bb094a16ff958bcc0a;hb=39b28bffc195348b93294b5fa0a8b9e87ea7317a;hp=c05bae66dfa5d302ecce8977cea96879268e804b;hpb=ad920945145a18895ef391511c92ef42e0e4c3d7;p=libucw.git diff --git a/ucw/url.c b/ucw/url.c index c05bae66..6d940018 100644 --- a/ucw/url.c +++ b/ucw/url.c @@ -10,11 +10,11 @@ * XXX: The buffer handling in this module is really horrible, but it works. */ -#include "ucw/lib.h" -#include "ucw/url.h" -#include "ucw/chartype.h" -#include "ucw/conf.h" -#include "ucw/prime.h" +#include +#include +#include +#include +#include #include #include @@ -30,6 +30,7 @@ static uns url_min_repeat_count = 0x7fffffff; static uns url_max_repeat_length = 0; static uns url_max_occurences = ~0U; +#ifndef TEST static struct cf_section url_config = { CF_ITEMS { CF_UNS("IgnoreSpaces", &url_ignore_spaces), @@ -46,6 +47,7 @@ static void CONSTRUCTOR url_init_config(void) { cf_declare_section("URL", &url_config, 0); } +#endif /* Escaping and de-escaping */ @@ -135,15 +137,15 @@ url_enescape(const char *s, char *d) if (d >= end) return URL_ERR_TOO_LONG; if (Calnum(c) || /* RFC 2396 (2.1-2.3): Only alphanumerics ... */ - c == '-' || c == '_' || c == '.' || c == '+' || c == '~' || /* ... and several other exceptions ... */ - c == '!' || c == '*' || c == '\'' || c == '(' || c == ')' || - c == '/' || c == '?' || c == ':' || c == '@' || /* ... and reserved chars used for reserved purpose */ - c == '=' || c == '&' || c == '#' || c == ';' || - c == '$' || c == '+' || c == ',') + c == '!' || c == '*' || c == '\'' || c == '(' || c == ')' || /* ... and some exceptions and reserved chars */ + c == '$' || c == '-' || c == '_' || c == '.' || c == '+' || + c == ',' || c == '=' || c == '&' || c == '#' || c == ';' || + c == '/' || c == '?' || c == ':' || c == '@' || c == '~' + ) *d++ = *s++; else { - uns val = ((byte)*s < NCC_MAX) ? NCC_CHARS[(byte)*s] : *s; + uns val = (byte)(((byte)*s < NCC_MAX) ? NCC_CHARS[(byte)*s] : *s); *d++ = '%'; *d++ = enhex(val >> 4); *d++ = enhex(val & 0x0f); @@ -163,14 +165,14 @@ url_enescape_friendly(const char *src, char *dest) { if (dest >= end) return URL_ERR_TOO_LONG; - if (*srcb < NCC_MAX) + if ((byte)*srcb < NCC_MAX) *dest++ = NCC_CHARS[*srcb++]; else if (*srcb >= 0x20 && *srcb < 0x7f) *dest++ = *srcb++; else { *dest++ = '%'; - *dest++ = enhex(*srcb >> 4); + *dest++ = enhex((byte)*srcb >> 4); *dest++ = enhex(*srcb++ & 0x0f); } }