From 0d42b49e3023c8ef2d417c0554fd351ace366c6e Mon Sep 17 00:00:00 2001 From: hniksic Date: Fri, 31 Mar 2000 06:04:54 -0800 Subject: [PATCH] [svn] Commit really old change. --- src/ChangeLog | 14 ++++++++++++++ src/url.c | 27 +++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 5b5c5742..663883c8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +1998-12-01 Hrvoje Niksic + + * url.c (UNSAFE_CHAR): New macro. + (contains_unsafe): Use it. + (encode_string): Ditto. + +1998-12-01 Hrvoje Niksic + + * main.c (i18n_initialize): Use LC_MESSAGES only if available. + +2000-03-31 Hrvoje Niksic + + * Use TOUPPER/TOLOWER. + 1998-12-22 Alexander V. Lukyanov * ftp-opie.c (btoe): Zero-terminate OSTORE. diff --git a/src/url.c b/src/url.c index 33aa37b8..c42c1e64 100644 --- a/src/url.c +++ b/src/url.c @@ -53,14 +53,17 @@ extern int errno; /* A list of unsafe characters for encoding, as per RFC1738. '@' and ':' (not listed in RFC) were added because of user/password - encoding, and \033 for safe printing. */ + encoding. */ #ifndef WINDOWS -# define URL_UNSAFE " <>\"#%{}|\\^~[]`@:\033" +# define URL_UNSAFE_CHARS "<>\"#%{}|\\^~[]`@:" #else /* WINDOWS */ -# define URL_UNSAFE " <>\"%{}|\\^[]`\033" +# define URL_UNSAFE_CHARS "<>\"%{}|\\^[]`" #endif /* WINDOWS */ +#define UNSAFE_CHAR(c) (((c) >= 0 && (c) <= 32) \ + || strchr (URL_UNSAFE_CHARS, c)) + /* If S contains unsafe characters, free it and replace it with a version that doesn't. */ #define URL_CLEANSE(s) do \ @@ -154,9 +157,9 @@ skip_url (const char *url) { int i; - if (toupper (url[0]) == 'U' - && toupper (url[1]) == 'R' - && toupper (url[2]) == 'L' + if (TOUPPER (url[0]) == 'U' + && TOUPPER (url[1]) == 'R' + && TOUPPER (url[2]) == 'L' && url[3] == ':') { /* Skip blanks. */ @@ -172,7 +175,7 @@ int contains_unsafe (const char *s) { for (; *s; s++) - if (strchr (URL_UNSAFE, *s)) + if (UNSAFE_CHAR (*s)) return 1; return 0; } @@ -209,8 +212,8 @@ decode_string (char *s) *p = '\0'; } -/* Encodes the unsafe characters (listed in URL_UNSAFE) in a given - string, returning a malloc-ed %XX encoded string. */ +/* Encodes the unsafe characters (listed in URL_UNSAFE_CHARS) in a + given string, returning a malloc-ed %XX encoded string. */ char * encode_string (const char *s) { @@ -220,12 +223,12 @@ encode_string (const char *s) b = s; for (i = 0; *s; s++, i++) - if (strchr (URL_UNSAFE, *s)) + if (UNSAFE_CHAR (*s)) i += 2; /* Two more characters (hex digits) */ res = (char *)xmalloc (i + 1); s = b; for (p = res; *s; s++) - if (strchr (URL_UNSAFE, *s)) + if (UNSAFE_CHAR (*s)) { const unsigned char c = *s; *p++ = '%'; @@ -464,7 +467,7 @@ parseurl (const char *url, struct urlinfo *u, int strict) { u->ftp_type = process_ftp_type (u->path); /* #### We don't handle type `d' correctly yet. */ - if (!u->ftp_type || toupper (u->ftp_type) == 'D') + if (!u->ftp_type || TOUPPER (u->ftp_type) == 'D') u->ftp_type = 'I'; } DEBUGP (("opath %s -> ", u->path));