diff options
author | corvid <corvid@lavabit.com> | 2011-11-11 04:26:41 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2011-11-11 04:26:41 +0000 |
commit | 980fe05f47b9d6dd8626b5ea021e2c16807ff5ca (patch) | |
tree | 2e5670d74d8fcfb8e7f6b84ffaf5f77b74855746 /src/cache.c | |
parent | 119aa95ed6bc612dd4ef7a3121d9bf220148aaa4 (diff) |
locale-independent ASCII character case handling
Basically, I and i are different letters in Turkic languages, and this
causes problems for str(n)casecmp and toupper/tolower in these locales
when dillo is dealing with ASCII.
Diffstat (limited to 'src/cache.c')
-rw-r--r-- | src/cache.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/cache.c b/src/cache.c index 15869ac6..11c7faf3 100644 --- a/src/cache.c +++ b/src/cache.c @@ -13,7 +13,6 @@ * Dillo's cache module */ -#include <ctype.h> /* for tolower */ #include <sys/types.h> #include <stdlib.h> @@ -521,7 +520,7 @@ const char *a_Cache_set_content_type(const DilloUrl *url, const char *ctype, /* META only gives charset; use detected MIME type too */ entry->TypeNorm = dStrconcat(entry->TypeDet, ctype, NULL); } else if (*from == 'm' && - !dStrncasecmp(ctype, "text/xhtml", 10)) { + !dStrnAsciiCasecmp(ctype, "text/xhtml", 10)) { /* WORKAROUND: doxygen uses "text/xhtml" in META */ entry->TypeNorm = dStrdup(entry->TypeDet); } @@ -584,7 +583,7 @@ static char *Cache_parse_field(const char *header, const char *fieldname) for (i = 0; header[i]; i++) { /* Search fieldname */ for (j = 0; fieldname[j]; j++) - if (tolower(fieldname[j]) != tolower(header[i + j])) + if (D_ASCII_TOLOWER(fieldname[j]) != D_ASCII_TOLOWER(header[i + j])) break; if (fieldname[j]) { /* skip to next line */ @@ -620,7 +619,7 @@ static Dlist *Cache_parse_multiple_fields(const char *header, for (i = 0; header[i]; i++) { /* Search fieldname */ for (j = 0; fieldname[j]; j++) - if (tolower(fieldname[j]) != tolower(header[i + j])) + if (D_ASCII_TOLOWER(fieldname[j]) != D_ASCII_TOLOWER(header[i + j])) break; if (fieldname[j]) { /* skip to next line */ @@ -694,8 +693,8 @@ static void Cache_parse_header(CacheEntry_t *entry) entry->Flags |= CA_TempRedirect; /* 302 Temporary Redirect */ if (URL_FLAGS(location_url) & (URL_Post + URL_Get) && - dStrcasecmp(URL_SCHEME(location_url), "dpi") == 0 && - dStrcasecmp(URL_SCHEME(entry->Url), "dpi") != 0) { + dStrAsciiCasecmp(URL_SCHEME(location_url), "dpi") == 0 && + dStrAsciiCasecmp(URL_SCHEME(entry->Url), "dpi") != 0) { /* Forbid dpi GET and POST from non dpi-generated urls */ MSG("Redirection Denied! '%s' -> '%s'\n", URL_STR(entry->Url), URL_STR(location_url)); @@ -734,7 +733,7 @@ static void Cache_parse_header(CacheEntry_t *entry) * If Transfer-Encoding is present, Content-Length must be ignored. * If the Transfer-Encoding is non-identity, it is an error. */ - if (dStrcasecmp(encoding, "identity")) + if (dStrAsciiCasecmp(encoding, "identity")) MSG_HTTP("Content-Length and non-identity Transfer-Encoding " "headers both present.\n"); } else { @@ -1045,9 +1044,9 @@ static void Cache_auth_entry(CacheEntry_t *entry, BrowserWindow *bw) */ int a_Cache_download_enabled(const DilloUrl *url) { - if (!dStrcasecmp(URL_SCHEME(url), "http") || - !dStrcasecmp(URL_SCHEME(url), "https") || - !dStrcasecmp(URL_SCHEME(url), "ftp")) + if (!dStrAsciiCasecmp(URL_SCHEME(url), "http") || + !dStrAsciiCasecmp(URL_SCHEME(url), "https") || + !dStrAsciiCasecmp(URL_SCHEME(url), "ftp")) return 1; return 0; } |