diff options
Diffstat (limited to 'dpi')
-rw-r--r-- | dpi/bookmarks.c | 2 | ||||
-rw-r--r-- | dpi/cookies.c | 38 | ||||
-rw-r--r-- | dpi/datauri.c | 8 | ||||
-rw-r--r-- | dpi/downloads.cc | 2 | ||||
-rw-r--r-- | dpi/dpiutil.c | 11 | ||||
-rw-r--r-- | dpi/file.c | 33 | ||||
-rw-r--r-- | dpi/ftp.c | 10 | ||||
-rw-r--r-- | dpi/https.c | 4 |
8 files changed, 56 insertions, 52 deletions
diff --git a/dpi/bookmarks.c b/dpi/bookmarks.c index 6e9cb3df..6932d2f0 100644 --- a/dpi/bookmarks.c +++ b/dpi/bookmarks.c @@ -442,7 +442,7 @@ static void Unencode_str(char *e_str) if (*e == '+') { *p = ' '; } else if (*e == '%') { - if (dStrncasecmp(e, "%0D%0A", 6) == 0) { + if (dStrnAsciiCasecmp(e, "%0D%0A", 6) == 0) { *p = '\n'; e += 5; } else { diff --git a/dpi/cookies.c b/dpi/cookies.c index 734dc016..93048a5c 100644 --- a/dpi/cookies.c +++ b/dpi/cookies.c @@ -158,7 +158,7 @@ static int Domain_node_cmp(const void *v1, const void *v2) { const DomainNode *n1 = v1, *n2 = v2; - return dStrcasecmp(n1->domain, n2->domain); + return dStrAsciiCasecmp(n1->domain, n2->domain); } /* @@ -169,7 +169,7 @@ static int Domain_node_by_domain_cmp(const void *v1, const void *v2) const DomainNode *node = v1; const char *domain = v2; - return dStrcasecmp(node->domain, domain); + return dStrAsciiCasecmp(node->domain, domain); } /* @@ -468,7 +468,7 @@ static int Cookies_get_month(const char *month_name) int i; for (i = 0; i < 12; i++) { - if (!dStrncasecmp(months[i], month_name, 3)) + if (!dStrnAsciiCasecmp(months[i], month_name, 3)) return i; } return -1; @@ -821,15 +821,15 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date) cookie->expires_at = mktime(tm); if (cookie->expires_at == (time_t) -1) cookie->expires_at = cookies_future_time; - } else if (dStrcasecmp(attr, "Path") == 0) { + } else if (dStrAsciiCasecmp(attr, "Path") == 0) { value = Cookies_parse_value(&str); dFree(cookie->path); cookie->path = value; - } else if (dStrcasecmp(attr, "Domain") == 0) { + } else if (dStrAsciiCasecmp(attr, "Domain") == 0) { value = Cookies_parse_value(&str); dFree(cookie->domain); cookie->domain = value; - } else if (dStrcasecmp(attr, "Max-Age") == 0) { + } else if (dStrAsciiCasecmp(attr, "Max-Age") == 0) { value = Cookies_parse_value(&str); if (isdigit(*value) || *value == '-') { time_t now = time(NULL); @@ -845,7 +845,7 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date) expires = max_age = TRUE; } dFree(value); - } else if (dStrcasecmp(attr, "Expires") == 0) { + } else if (dStrAsciiCasecmp(attr, "Expires") == 0) { if (!max_age) { value = Cookies_parse_value(&str); Cookies_unquote_string(value); @@ -870,10 +870,10 @@ static CookieData_t *Cookies_parse(char *cookie_str, const char *server_date) } else { Cookies_eat_value(&str); } - } else if (dStrcasecmp(attr, "Secure") == 0) { + } else if (dStrAsciiCasecmp(attr, "Secure") == 0) { cookie->secure = TRUE; Cookies_eat_value(&str); - } else if (dStrcasecmp(attr, "HttpOnly") == 0) { + } else if (dStrAsciiCasecmp(attr, "HttpOnly") == 0) { Cookies_eat_value(&str); } else { MSG("Cookie contains unknown attribute: '%s'\n", attr); @@ -992,7 +992,7 @@ static bool_t Cookies_domain_matches(char *A, char *B) * don't, so: No. */ - if (!dStrcasecmp(A, B)) + if (!dStrAsciiCasecmp(A, B)) return TRUE; if (Cookies_domain_is_ip(B)) @@ -1002,7 +1002,7 @@ static bool_t Cookies_domain_matches(char *A, char *B) if (diff > 0) { /* B is the tail of A, and the match is preceded by a '.' */ - return (dStrcasecmp(A + diff, B) == 0 && A[diff - 1] == '.'); + return (dStrAsciiCasecmp(A + diff, B) == 0 && A[diff - 1] == '.'); } else { return FALSE; } @@ -1050,7 +1050,7 @@ static uint_t Cookies_internal_dots_required(const char *host) for (i = 0; i < tld_num; i++) { if (strlen(tlds[i]) == (uint_t) tld_len && - !dStrncasecmp(tlds[i], host + start, tld_len)) { + !dStrnAsciiCasecmp(tlds[i], host + start, tld_len)) { _MSG("TLD code matched %s\n", tlds[i]); ret++; break; @@ -1221,7 +1221,7 @@ static char *Cookies_get(char *url_host, char *url_path, matching_cookies = dList_new(8); /* Check if the protocol is secure or not */ - is_ssl = (!dStrcasecmp(url_scheme, "https")); + is_ssl = (!dStrAsciiCasecmp(url_scheme, "https")); is_ip_addr = Cookies_domain_is_ip(url_host); @@ -1350,11 +1350,11 @@ static int Cookie_control_init(void) rule[j++] = line[i++]; rule[j] = '\0'; - if (dStrcasecmp(rule, "ACCEPT") == 0) + if (dStrAsciiCasecmp(rule, "ACCEPT") == 0) cc.action = COOKIE_ACCEPT; - else if (dStrcasecmp(rule, "ACCEPT_SESSION") == 0) + else if (dStrAsciiCasecmp(rule, "ACCEPT_SESSION") == 0) cc.action = COOKIE_ACCEPT_SESSION; - else if (dStrcasecmp(rule, "DENY") == 0) + else if (dStrAsciiCasecmp(rule, "DENY") == 0) cc.action = COOKIE_DENY; else { MSG("Cookies: rule '%s' for domain '%s' is not recognised.\n", @@ -1363,7 +1363,7 @@ static int Cookie_control_init(void) } cc.domain = dStrdup(domain); - if (dStrcasecmp(cc.domain, "DEFAULT") == 0) { + if (dStrAsciiCasecmp(cc.domain, "DEFAULT") == 0) { /* Set the default action */ default_action = cc.action; dFree(cc.domain); @@ -1404,13 +1404,13 @@ static CookieControlAction Cookies_control_check_domain(const char *domain) if (ccontrol[i].domain[0] == '.') { diff = strlen(domain) - strlen(ccontrol[i].domain); if (diff >= 0) { - if (dStrcasecmp(domain + diff, ccontrol[i].domain) != 0) + if (dStrAsciiCasecmp(domain + diff, ccontrol[i].domain) != 0) continue; } else { continue; } } else { - if (dStrcasecmp(domain, ccontrol[i].domain) != 0) + if (dStrAsciiCasecmp(domain, ccontrol[i].domain) != 0) continue; } diff --git a/dpi/datauri.c b/dpi/datauri.c index 6d7acfa7..9088c6aa 100644 --- a/dpi/datauri.c +++ b/dpi/datauri.c @@ -226,14 +226,14 @@ static char *datauri_get_mime(char *url) char *mime_type = NULL, *p; size_t len = 0; - if (dStrncasecmp(url, "data:", 5) == 0) { + if (dStrnAsciiCasecmp(url, "data:", 5) == 0) { if ((p = strchr(url, ',')) && p - url < 256) { url += 5; len = p - url; strncpy(buf, url, len); buf[len] = 0; /* strip ";base64" */ - if (len >= 7 && dStrcasecmp(buf + len - 7, ";base64") == 0) { + if (len >= 7 && dStrAsciiCasecmp(buf + len - 7, ";base64") == 0) { len -= 7; buf[len] = 0; } @@ -242,7 +242,7 @@ static char *datauri_get_mime(char *url) /* that's it, now handle omitted types */ if (len == 0) { mime_type = dStrdup("text/plain;charset=US-ASCII"); - } else if (!dStrncasecmp(buf, "charset", 7)) { + } else if (!dStrnAsciiCasecmp(buf, "charset", 7)) { mime_type = dStrconcat("text/plain", buf, NULL); } else { mime_type = dStrdup(buf); @@ -262,7 +262,7 @@ static unsigned char *datauri_get_data(char *url, size_t *p_sz) unsigned char *data = NULL; if ((p = strchr(url, ',')) && p - url >= 12 && /* "data:;base64" */ - dStrncasecmp(p - 7, ";base64", 7) == 0) { + dStrnAsciiCasecmp(p - 7, ";base64", 7) == 0) { is_base64 = 1; } diff --git a/dpi/downloads.cc b/dpi/downloads.cc index d9ccb380..418dbd1b 100644 --- a/dpi/downloads.cc +++ b/dpi/downloads.cc @@ -327,7 +327,7 @@ DLItem::DLItem(const char *full_filename, const char *url, DLAction action) /* escape "'" character for the shell. Is it necessary? */ esc_url = Escape_uri_str(url, "'"); /* avoid malicious SMTP relaying with FTP urls */ - if (dStrncasecmp(esc_url, "ftp:/", 5) == 0) + if (dStrnAsciiCasecmp(esc_url, "ftp:/", 5) == 0) Filter_smtp_hack(esc_url); dl_argv = new char*[8]; int i = 0; diff --git a/dpi/dpiutil.c b/dpi/dpiutil.c index e29d529f..45100be2 100644 --- a/dpi/dpiutil.c +++ b/dpi/dpiutil.c @@ -68,8 +68,10 @@ char *Unescape_uri_str(const char *s) if (strchr(s, '%')) { for (p = buf; (*p = *s); ++s, ++p) { if (*p == '%' && isxdigit(s[1]) && isxdigit(s[2])) { - *p = (isdigit(s[1]) ? (s[1] - '0') : toupper(s[1]) - 'A' + 10)*16; - *p += isdigit(s[2]) ? (s[2] - '0') : toupper(s[2]) - 'A' + 10; + *p = (isdigit(s[1]) ? (s[1] - '0') + : D_ASCII_TOUPPER(s[1]) - 'A' + 10) * 16; + *p += isdigit(s[2]) ? (s[2] - '0') + : D_ASCII_TOUPPER(s[2]) - 'A' + 10; s += 2; } } @@ -121,7 +123,7 @@ char *Unescape_html_str(const char *str) for (i = 0, j = 0; str[i]; ++i) { if (str[i] == '&') { for (k = 0; k < 5; ++k) { - if (!dStrncasecmp(str + i, unsafe_rep[k], unsafe_rep_len[k])) { + if (!dStrnAsciiCasecmp(str + i, unsafe_rep[k], unsafe_rep_len[k])) { i += unsafe_rep_len[k] - 1; break; } @@ -154,7 +156,8 @@ char *Filter_smtp_hack(char *url) memmove(url + i, url + i + 1, strlen(url + i)); --i; } else if (c == '%' && url[i+1] == '0' && - (tolower(url[i+2]) == 'a' || tolower(url[i+2]) == 'd')) { + (D_ASCII_TOLOWER(url[i+2]) == 'a' || + D_ASCII_TOLOWER(url[i+2]) == 'd')) { memmove(url + i, url + i + 3, strlen(url + i + 2)); --i; } @@ -15,7 +15,7 @@ * With new HTML layout. */ -#include <ctype.h> /* for tolower */ +#include <ctype.h> /* for isspace */ #include <errno.h> /* for errno */ #include <stdio.h> #include <stdlib.h> @@ -142,12 +142,12 @@ static const char *File_get_content_type_from_data(void *Data, size_t Size) /* HTML try */ for (i = 0; i < Size && dIsspace(p[i]); ++i); - if ((Size - i >= 5 && !dStrncasecmp(p+i, "<html", 5)) || - (Size - i >= 5 && !dStrncasecmp(p+i, "<head", 5)) || - (Size - i >= 6 && !dStrncasecmp(p+i, "<title", 6)) || - (Size - i >= 14 && !dStrncasecmp(p+i, "<!doctype html", 14)) || + if ((Size - i >= 5 && !dStrnAsciiCasecmp(p+i, "<html", 5)) || + (Size - i >= 5 && !dStrnAsciiCasecmp(p+i, "<head", 5)) || + (Size - i >= 6 && !dStrnAsciiCasecmp(p+i, "<title", 6)) || + (Size - i >= 14 && !dStrnAsciiCasecmp(p+i, "<!doctype html", 14)) || /* this line is workaround for FTP through the Squid proxy */ - (Size - i >= 17 && !dStrncasecmp(p+i, "<!-- HTML listing", 17))) { + (Size - i >= 17 && !dStrnAsciiCasecmp(p+i, "<!-- HTML listing", 17))) { Type = 1; @@ -502,18 +502,18 @@ static const char *File_ext(const char *filename) e++; - if (!dStrcasecmp(e, "gif")) { + if (!dStrAsciiCasecmp(e, "gif")) { return "image/gif"; - } else if (!dStrcasecmp(e, "jpg") || - !dStrcasecmp(e, "jpeg")) { + } else if (!dStrAsciiCasecmp(e, "jpg") || + !dStrAsciiCasecmp(e, "jpeg")) { return "image/jpeg"; - } else if (!dStrcasecmp(e, "png")) { + } else if (!dStrAsciiCasecmp(e, "png")) { return "image/png"; - } else if (!dStrcasecmp(e, "html") || - !dStrcasecmp(e, "htm") || - !dStrcasecmp(e, "shtml")) { + } else if (!dStrAsciiCasecmp(e, "html") || + !dStrAsciiCasecmp(e, "htm") || + !dStrAsciiCasecmp(e, "shtml")) { return "text/html"; - } else if (!dStrcasecmp(e, "txt")) { + } else if (!dStrAsciiCasecmp(e, "txt")) { return "text/plain"; } else { return NULL; @@ -712,7 +712,8 @@ static int File_send_file(ClientInfo *client) /* Check for gzipped file */ namelen = strlen(client->filename); - if (namelen > 3 && !dStrcasecmp(client->filename + namelen - 3, ".gz")) { + if (namelen > 3 && + !dStrAsciiCasecmp(client->filename + namelen - 3, ".gz")) { gzipped = TRUE; namelen -= 3; } @@ -804,7 +805,7 @@ static char *File_normalize_path(const char *orig) str += 5; /* Skip "localhost" */ - if (dStrncasecmp(str, "//localhost/", 12) == 0) + if (dStrnAsciiCasecmp(str, "//localhost/", 12) == 0) str += 11; /* Skip packed slashes, and leave just one */ @@ -98,12 +98,12 @@ static int a_Misc_get_content_type_from_data2(void *Data, size_t Size, /* HTML try */ for (i = 0; i < Size && dIsspace(p[i]); ++i); - if ((Size - i >= 5 && !dStrncasecmp(p+i, "<html", 5)) || - (Size - i >= 5 && !dStrncasecmp(p+i, "<head", 5)) || - (Size - i >= 6 && !dStrncasecmp(p+i, "<title", 6)) || - (Size - i >= 14 && !dStrncasecmp(p+i, "<!doctype html", 14)) || + if ((Size - i >= 5 && !dStrnAsciiCasecmp(p+i, "<html", 5)) || + (Size - i >= 5 && !dStrnAsciiCasecmp(p+i, "<head", 5)) || + (Size - i >= 6 && !dStrnAsciiCasecmp(p+i, "<title", 6)) || + (Size - i >= 14 && !dStrnAsciiCasecmp(p+i, "<!doctype html", 14)) || /* this line is workaround for FTP through the Squid proxy */ - (Size - i >= 17 && !dStrncasecmp(p+i, "<!-- HTML listing", 17))) { + (Size - i >= 17 && !dStrnAsciiCasecmp(p+i, "<!-- HTML listing", 17))) { Type = 1; st = 0; diff --git a/dpi/https.c b/dpi/https.c index bea9de10..c2becdae 100644 --- a/dpi/https.c +++ b/dpi/https.c @@ -360,9 +360,9 @@ static int get_network_connection(char * url) char * url_look_up = NULL; /*Determine how much of url we chop off as unneeded*/ - if (dStrncasecmp(url, "https://", 8) == 0){ + if (dStrnAsciiCasecmp(url, "https://", 8) == 0){ url_offset = 8; - } else if (dStrncasecmp(url, "http://", 7) == 0) { + } else if (dStrnAsciiCasecmp(url, "http://", 7) == 0) { url_offset = 7; portnum = 80; } |