From 980fe05f47b9d6dd8626b5ea021e2c16807ff5ca Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 11 Nov 2011 04:26:41 +0000 Subject: 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. --- src/cache.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/cache.c') 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 /* for tolower */ #include #include @@ -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; } -- cgit v1.2.3