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/IO/http.c | 4 +-- src/IO/mime.c | 4 +-- src/auth.c | 16 +++++------ src/cache.c | 19 +++++++------ src/capi.c | 19 ++++++------- src/colors.c | 2 +- src/cookies.c | 12 ++++----- src/css.cc | 6 ++--- src/cssparser.cc | 58 +++++++++++++++++++-------------------- src/decode.c | 29 ++++++++++---------- src/form.cc | 46 +++++++++++++++---------------- src/html.cc | 79 ++++++++++++++++++++++++++++-------------------------- src/keys.cc | 6 ++--- src/misc.c | 41 ++++++++++++++-------------- src/prefsparser.cc | 12 ++++----- src/table.cc | 6 ++--- src/uicmd.cc | 2 +- src/url.c | 9 ++++--- src/web.cc | 2 +- 19 files changed, 189 insertions(+), 183 deletions(-) (limited to 'src') diff --git a/src/IO/http.c b/src/IO/http.c index 0c34a6b6..3e87f912 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -480,7 +480,7 @@ static int Http_must_use_proxy(const DilloUrl *url) for (p = np; (tok = dStrsep(&p, " ")); ) { int start = host_len - strlen(tok); - if (start >= 0 && dStrcasecmp(host + start, tok) == 0) { + if (start >= 0 && dStrAsciiCasecmp(host + start, tok) == 0) { /* no_proxy token is suffix of host string */ ret = 0; break; @@ -719,7 +719,7 @@ static HostConnection_t *Http_host_connection_get(const char *host) for (i = 0; i < dList_length(host_connections); i++) { hc = (HostConnection_t*) dList_nth_data(host_connections, i); - if (dStrcasecmp(host, hc->host) == 0) + if (dStrAsciiCasecmp(host, hc->host) == 0) return hc; } diff --git a/src/IO/mime.c b/src/IO/mime.c index 19dc601a..3606d23c 100644 --- a/src/IO/mime.c +++ b/src/IO/mime.c @@ -67,7 +67,7 @@ static Viewer_t Mime_minor_type_fetch(const char *Key, uint_t Size) if (Size) { for ( i = 0; i < MimeMinItemsSize; ++i ) - if (dStrncasecmp(Key, MimeMinItems[i].Name, Size) == 0) + if (dStrnAsciiCasecmp(Key, MimeMinItems[i].Name, Size) == 0) return MimeMinItems[i].Data; } return NULL; @@ -83,7 +83,7 @@ static Viewer_t Mime_major_type_fetch(const char *Key, uint_t Size) if (Size) { for ( i = 0; i < MimeMajItemsSize; ++i ) - if (dStrncasecmp(Key, MimeMajItems[i].Name, Size) == 0) + if (dStrnAsciiCasecmp(Key, MimeMajItems[i].Name, Size) == 0) return MimeMajItems[i].Data; } return NULL; diff --git a/src/auth.c b/src/auth.c index 0148521b..d6ca8504 100644 --- a/src/auth.c +++ b/src/auth.c @@ -228,7 +228,7 @@ static int Auth_parse_token_value(AuthParse_t *auth_parse, char **auth, static int Auth_parse_basic_challenge_cb(AuthParse_t *auth_parse, char *token, const char *value) { - if (dStrcasecmp("realm", token) == 0) { + if (dStrAsciiCasecmp("realm", token) == 0) { if (!auth_parse->realm) auth_parse->realm = strdup(value); return 0; /* end parsing */ @@ -243,7 +243,7 @@ static int Auth_parse_digest_challenge_cb(AuthParse_t *auth_parse, char *token, { const char *const fn = "Auth_parse_digest_challenge_cb"; - if (!dStrcasecmp("realm", token) && !auth_parse->realm) + if (!dStrAsciiCasecmp("realm", token) && !auth_parse->realm) auth_parse->realm = strdup(value); else if (!strcmp("domain", token) && !auth_parse->domain) auth_parse->domain = strdup(value); @@ -252,9 +252,9 @@ static int Auth_parse_digest_challenge_cb(AuthParse_t *auth_parse, char *token, else if (!strcmp("opaque", token) && !auth_parse->opaque) auth_parse->opaque = strdup(value); else if (strcmp("stale", token) == 0) { - if (dStrcasecmp("true", value) == 0) + if (dStrAsciiCasecmp("true", value) == 0) auth_parse->stale = 1; - else if (dStrcasecmp("false", value) == 0) + else if (dStrAsciiCasecmp("false", value) == 0) auth_parse->stale = 0; else { MSG("%s: Invalid stale value: %s\n", fn, value); @@ -359,8 +359,8 @@ static AuthHost_t *Auth_host_by_url(const DilloUrl *url) int i; for (i = 0; (host = dList_nth_data(auth_hosts, i)); i++) - if (((dStrcasecmp(URL_SCHEME(url), host->scheme) == 0) && - (dStrcasecmp(URL_AUTHORITY(url), host->authority) == 0))) + if (((dStrAsciiCasecmp(URL_SCHEME(url), host->scheme) == 0) && + (dStrAsciiCasecmp(URL_AUTHORITY(url), host->authority) == 0))) return host; return NULL; @@ -672,11 +672,11 @@ int a_Auth_do_auth(Dlist *challenges, const DilloUrl *url) char *chal; for (i = 0; (chal = dList_nth_data(challenges, i)); ++i) - if (!dStrncasecmp(chal, "Digest ", 7)) + if (!dStrnAsciiCasecmp(chal, "Digest ", 7)) if (Auth_do_auth(chal, DIGEST, url)) return 1; for (i = 0; (chal = dList_nth_data(challenges, i)); ++i) - if (!dStrncasecmp(chal, "Basic ", 6)) + if (!dStrnAsciiCasecmp(chal, "Basic ", 6)) if (Auth_do_auth(chal, BASIC, url)) return 1; 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; } diff --git a/src/capi.c b/src/capi.c index c3812acc..281eb6f3 100644 --- a/src/capi.c +++ b/src/capi.c @@ -229,7 +229,7 @@ int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url) const DilloUrl *referer; int allow = FALSE; - if (dStrcasecmp(URL_SCHEME(url), "dpi") == 0) { + if (dStrAsciiCasecmp(URL_SCHEME(url), "dpi") == 0) { if (!(URL_FLAGS(url) & (URL_Post + URL_Get))) { allow = TRUE; } else if (!(URL_FLAGS(url) & URL_Post) && @@ -239,7 +239,7 @@ int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url) /* only allow GET&POST dpi-requests from dpi-generated urls */ if (a_Nav_stack_size(bw)) { referer = a_History_get_url(NAV_TOP_UIDX(bw)); - if (dStrcasecmp(URL_SCHEME(referer), "dpi") == 0) { + if (dStrAsciiCasecmp(URL_SCHEME(referer), "dpi") == 0) { allow = TRUE; } } @@ -266,10 +266,10 @@ static int Capi_url_uses_dpi(DilloUrl *url, char **server_ptr) char *p, *server = NULL, *url_str = URL_STR(url); Dstr *tmp; - if ((dStrncasecmp(url_str, "http:", 5) == 0) || - (dStrncasecmp(url_str, "about:", 6) == 0)) { + if ((dStrnAsciiCasecmp(url_str, "http:", 5) == 0) || + (dStrnAsciiCasecmp(url_str, "about:", 6) == 0)) { /* URL doesn't use dpi (server = NULL) */ - } else if (dStrncasecmp(url_str, "dpi:/", 5) == 0) { + } else if (dStrnAsciiCasecmp(url_str, "dpi:/", 5) == 0) { /* dpi prefix, get this server's name */ if ((p = strchr(url_str + 5, '/')) != NULL) { server = dStrndup(url_str + 5, (uint_t)(p - url_str - 5)); @@ -388,7 +388,8 @@ static bool_t Capi_filters_test(const DilloUrl *wanted, *want_host = URL_HOST(wanted); if (want_host[0] == '\0') { ret = (req_host[0] == '\0' || - !dStrcasecmp(URL_SCHEME(wanted), "data")) ? TRUE : FALSE; + !dStrAsciiCasecmp(URL_SCHEME(wanted), "data")) + ? TRUE : FALSE; } else { /* This will regard "www.dillo.org" and "www.dillo.org." as * different, but it doesn't seem worth caring about. @@ -454,7 +455,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) } else if (Capi_url_uses_dpi(web->url, &server)) { /* dpi request */ if ((safe = a_Capi_dpi_verify_request(web->bw, web->url))) { - if (dStrcasecmp(scheme, "dpi") == 0) { + if (dStrAsciiCasecmp(scheme, "dpi") == 0) { if (strcmp(server, "vsource") == 0) { /* allow "view source" reload upon user request */ } else { @@ -478,7 +479,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) } dFree(server); - } else if (!dStrcasecmp(scheme, "http")) { + } else if (!dStrAsciiCasecmp(scheme, "http")) { /* http request */ if (reload) { a_Capi_conn_abort_by_url(web->url); @@ -491,7 +492,7 @@ int a_Capi_open_url(DilloWeb *web, CA_Callback_t Call, void *CbData) } use_cache = 1; - } else if (!dStrcasecmp(scheme, "about")) { + } else if (!dStrAsciiCasecmp(scheme, "about")) { /* internal request */ use_cache = 1; } diff --git a/src/colors.c b/src/colors.c index 5b647bb2..5d929a88 100644 --- a/src/colors.c +++ b/src/colors.c @@ -262,7 +262,7 @@ int32_t a_Color_parse (const char *subtag, int32_t default_color, int *err) high = NCOLORS - 1; while (low <= high) { mid = (low + high) / 2; - if ((ret = dStrcasecmp(cp, color_keyword[mid].key)) < 0) + if ((ret = dStrAsciiCasecmp(cp, color_keyword[mid].key)) < 0) high = mid - 1; else if (ret > 0) low = mid + 1; diff --git a/src/cookies.c b/src/cookies.c index eadd0322..0a1e94ff 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -284,11 +284,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", @@ -297,7 +297,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); @@ -338,13 +338,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/src/css.cc b/src/css.cc index d0bd8d95..1e703f2e 100644 --- a/src/css.cc +++ b/src/css.cc @@ -265,16 +265,16 @@ bool CssSimpleSelector::match (const DoctreeNode *n) { if (element != ELEMENT_ANY && element != n->element) return false; if (pseudo != NULL && - (n->pseudo == NULL || dStrcasecmp (pseudo, n->pseudo) != 0)) + (n->pseudo == NULL || dStrAsciiCasecmp (pseudo, n->pseudo) != 0)) return false; - if (id != NULL && (n->id == NULL || dStrcasecmp (id, n->id) != 0)) + if (id != NULL && (n->id == NULL || dStrAsciiCasecmp (id, n->id) != 0)) return false; if (klass != NULL) { for (int i = 0; i < klass->size (); i++) { bool found = false; if (n->klass != NULL) { for (int j = 0; j < n->klass->size (); j++) { - if (dStrcasecmp (klass->get(i), n->klass->get(j)) == 0) { + if (dStrAsciiCasecmp (klass->get(i), n->klass->get(j)) == 0) { found = true; break; } diff --git a/src/cssparser.cc b/src/cssparser.cc index e58a52e1..6d5b3768 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -674,7 +674,7 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type) case CSS_TYPE_ENUM: if (ttype == CSS_TK_SYMBOL) { for (i = 0; Css_property_info[prop].enum_symbols[i]; i++) - if (dStrcasecmp(tval, + if (dStrAsciiCasecmp(tval, Css_property_info[prop].enum_symbols[i]) == 0) return true; } @@ -682,11 +682,11 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type) case CSS_TYPE_MULTI_ENUM: if (ttype == CSS_TK_SYMBOL) { - if (dStrcasecmp(tval, "none") == 0) { + if (dStrAsciiCasecmp(tval, "none") == 0) { return true; } else { for (i = 0; Css_property_info[prop].enum_symbols[i]; i++) { - if (dStrcasecmp(tval, + if (dStrAsciiCasecmp(tval, Css_property_info[prop].enum_symbols[i]) == 0) return true; } @@ -703,14 +703,14 @@ bool CssParser::tokenMatchesProperty(CssPropertyName prop, CssValueType *type) case CSS_TYPE_SIGNED_LENGTH: if (ttype == CSS_TK_DECINT || ttype == CSS_TK_FLOAT || - (ttype == CSS_TK_SYMBOL && dStrcasecmp(tval, "auto") == 0)) + (ttype == CSS_TK_SYMBOL && dStrAsciiCasecmp(tval, "auto") == 0)) return true; break; case CSS_TYPE_COLOR: if ((ttype == CSS_TK_COLOR || ttype == CSS_TK_SYMBOL) && - (dStrcasecmp(tval, "rgb") == 0 || + (dStrAsciiCasecmp(tval, "rgb") == 0 || a_Color_parse(tval, -1, &err) != -1)) return true; break; @@ -838,7 +838,7 @@ bool CssParser::parseValue(CssPropertyName prop, case CSS_TYPE_ENUM: if (ttype == CSS_TK_SYMBOL) { for (i = 0; Css_property_info[prop].enum_symbols[i]; i++) - if (dStrcasecmp(tval, + if (dStrAsciiCasecmp(tval, Css_property_info[prop].enum_symbols[i]) == 0) { val->intVal = i; ret = true; @@ -853,10 +853,10 @@ bool CssParser::parseValue(CssPropertyName prop, ret = true; while (ttype == CSS_TK_SYMBOL) { - if (dStrcasecmp(tval, "none") != 0) { + if (dStrAsciiCasecmp(tval, "none") != 0) { for (i = 0, found = false; !found && Css_property_info[prop].enum_symbols[i]; i++) { - if (dStrcasecmp(tval, + if (dStrAsciiCasecmp(tval, Css_property_info[prop].enum_symbols[i]) == 0) val->intVal |= (1 << i); } @@ -877,32 +877,32 @@ bool CssParser::parseValue(CssPropertyName prop, if (!spaceSeparated && ttype == CSS_TK_SYMBOL) { ret = true; - if (dStrcasecmp(tval, "px") == 0) { + if (dStrAsciiCasecmp(tval, "px") == 0) { lentype = CSS_LENGTH_TYPE_PX; nextToken(); - } else if (dStrcasecmp(tval, "mm") == 0) { + } else if (dStrAsciiCasecmp(tval, "mm") == 0) { lentype = CSS_LENGTH_TYPE_MM; nextToken(); - } else if (dStrcasecmp(tval, "cm") == 0) { + } else if (dStrAsciiCasecmp(tval, "cm") == 0) { lentype = CSS_LENGTH_TYPE_MM; fval *= 10; nextToken(); - } else if (dStrcasecmp(tval, "in") == 0) { + } else if (dStrAsciiCasecmp(tval, "in") == 0) { lentype = CSS_LENGTH_TYPE_MM; fval *= 25.4; nextToken(); - } else if (dStrcasecmp(tval, "pt") == 0) { + } else if (dStrAsciiCasecmp(tval, "pt") == 0) { lentype = CSS_LENGTH_TYPE_MM; fval *= (25.4 / 72); nextToken(); - } else if (dStrcasecmp(tval, "pc") == 0) { + } else if (dStrAsciiCasecmp(tval, "pc") == 0) { lentype = CSS_LENGTH_TYPE_MM; fval *= (25.4 / 6); nextToken(); - } else if (dStrcasecmp(tval, "em") == 0) { + } else if (dStrAsciiCasecmp(tval, "em") == 0) { lentype = CSS_LENGTH_TYPE_EM; nextToken(); - } else if (dStrcasecmp(tval, "ex") == 0) { + } else if (dStrAsciiCasecmp(tval, "ex") == 0) { lentype = CSS_LENGTH_TYPE_EX; nextToken(); } else { @@ -927,7 +927,7 @@ bool CssParser::parseValue(CssPropertyName prop, ret = true; val->intVal = CSS_CREATE_LENGTH(fval, lentype); - } else if (ttype == CSS_TK_SYMBOL && dStrcasecmp(tval, "auto") == 0) { + } else if (ttype == CSS_TK_SYMBOL && !dStrAsciiCasecmp(tval, "auto")) { ret = true; val->intVal = CSS_LENGTH_TYPE_AUTO; nextToken(); @@ -943,7 +943,7 @@ bool CssParser::parseValue(CssPropertyName prop, ret = true; nextToken(); } else if (ttype == CSS_TK_SYMBOL) { - if (dStrcasecmp(tval, "rgb") == 0) { + if (dStrAsciiCasecmp(tval, "rgb") == 0) { nextToken(); if (parseRgbColor(&val->intVal)) ret = true; @@ -1022,7 +1022,7 @@ bool CssParser::parseWeight() if (ttype == CSS_TK_CHAR && tval[0] == '!') { nextToken(); if (ttype == CSS_TK_SYMBOL && - dStrcasecmp(tval, "important") == 0) { + dStrAsciiCasecmp(tval, "important") == 0) { nextToken(); return true; } @@ -1036,7 +1036,7 @@ bool CssParser::parseWeight() */ static int Css_property_info_cmp(const void *a, const void *b) { - return dStrcasecmp(((CssPropertyInfo *) a)->symbol, + return dStrAsciiCasecmp(((CssPropertyInfo *) a)->symbol, ((CssPropertyInfo *) b)->symbol); } @@ -1046,7 +1046,7 @@ static int Css_property_info_cmp(const void *a, const void *b) */ static int Css_shorthand_info_cmp(const void *a, const void *b) { - return dStrcasecmp(((CssShorthandInfo *) a)->symbol, + return dStrAsciiCasecmp(((CssShorthandInfo *) a)->symbol, ((CssShorthandInfo *) b)->symbol); } @@ -1391,7 +1391,7 @@ char * CssParser::parseUrl() Dstr *urlStr = NULL; if (ttype != CSS_TK_SYMBOL || - dStrcasecmp(tval, "url") != 0) + dStrAsciiCasecmp(tval, "url") != 0) return NULL; nextToken(); @@ -1437,7 +1437,7 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) nextToken(); if (ttype == CSS_TK_SYMBOL && - dStrcasecmp(tval, "url") == 0) + dStrAsciiCasecmp(tval, "url") == 0) urlStr = parseUrl(); else if (ttype == CSS_TK_STRING) urlStr = dStrdup (tval); @@ -1449,8 +1449,8 @@ void CssParser::parseImport(DilloHtml *html, DilloUrl *baseUrl) mediaSyntaxIsOK = false; mediaIsSelected = false; while (ttype == CSS_TK_SYMBOL) { - if (dStrcasecmp(tval, "all") == 0 || - dStrcasecmp(tval, "screen") == 0) + if (dStrAsciiCasecmp(tval, "all") == 0 || + dStrAsciiCasecmp(tval, "screen") == 0) mediaIsSelected = true; nextToken(); if (ttype == CSS_TK_CHAR && tval[0] == ',') { @@ -1491,8 +1491,8 @@ void CssParser::parseMedia() /* parse a comma-separated list of media */ while (ttype == CSS_TK_SYMBOL) { - if (dStrcasecmp(tval, "all") == 0 || - dStrcasecmp(tval, "screen") == 0) + if (dStrAsciiCasecmp(tval, "all") == 0 || + dStrAsciiCasecmp(tval, "screen") == 0) mediaIsSelected = true; nextToken(); if (ttype == CSS_TK_CHAR && tval[0] == ',') { @@ -1578,11 +1578,11 @@ void CssParser::parse(DilloHtml *html, DilloUrl *url, CssContext * context, parser.tval[0] == '@') { parser.nextToken(); if (parser.ttype == CSS_TK_SYMBOL) { - if (dStrcasecmp(parser.tval, "import") == 0 && + if (dStrAsciiCasecmp(parser.tval, "import") == 0 && html != NULL && importsAreAllowed) { parser.parseImport(html, url); - } else if (dStrcasecmp(parser.tval, "media") == 0) { + } else if (dStrAsciiCasecmp(parser.tval, "media") == 0) { parser.parseMedia(); } else { parser.ignoreStatement(); diff --git a/src/decode.c b/src/decode.c index 24067318..7ea3dc25 100644 --- a/src/decode.c +++ b/src/decode.c @@ -190,7 +190,7 @@ Decode *a_Decode_transfer_init(const char *format) { Decode *dc = NULL; - if (format && !dStrcasecmp(format, "chunked")) { + if (format && !dStrAsciiCasecmp(format, "chunked")) { int *chunk_remaining = dNew(int, 1); *chunk_remaining = 0; dc = dNew(Decode, 1); @@ -215,7 +215,8 @@ Decode *a_Decode_content_init(const char *format) Decode *dc = NULL; if (format && *format) { - if (!dStrcasecmp(format, "gzip") || !dStrcasecmp(format, "x-gzip")) { + if (!dStrAsciiCasecmp(format, "gzip") || + !dStrAsciiCasecmp(format, "x-gzip")) { z_stream *zs; _MSG("gzipped data!\n"); @@ -245,17 +246,17 @@ Decode *a_Decode_content_init(const char *format) */ static int Decode_is_ascii(const char *str) { - return (!(dStrcasecmp(str, "ASCII") && - dStrcasecmp(str, "US-ASCII") && - dStrcasecmp(str, "us") && - dStrcasecmp(str, "IBM367") && - dStrcasecmp(str, "cp367") && - dStrcasecmp(str, "csASCII") && - dStrcasecmp(str, "ANSI_X3.4-1968") && - dStrcasecmp(str, "iso-ir-6") && - dStrcasecmp(str, "ANSI_X3.4-1986") && - dStrcasecmp(str, "ISO_646.irv:1991") && - dStrcasecmp(str, "ISO646-US"))); + return (!(dStrAsciiCasecmp(str, "ASCII") && + dStrAsciiCasecmp(str, "US-ASCII") && + dStrAsciiCasecmp(str, "us") && + dStrAsciiCasecmp(str, "IBM367") && + dStrAsciiCasecmp(str, "cp367") && + dStrAsciiCasecmp(str, "csASCII") && + dStrAsciiCasecmp(str, "ANSI_X3.4-1968") && + dStrAsciiCasecmp(str, "iso-ir-6") && + dStrAsciiCasecmp(str, "ANSI_X3.4-1986") && + dStrAsciiCasecmp(str, "ISO_646.irv:1991") && + dStrAsciiCasecmp(str, "ISO646-US"))); } /* @@ -271,7 +272,7 @@ Decode *a_Decode_charset_init(const char *format) if (format && strlen(format) && - dStrcasecmp(format,"UTF-8") && + dStrAsciiCasecmp(format,"UTF-8") && !Decode_is_ascii(format)) { iconv_t ic = iconv_open("UTF-8", format); diff --git a/src/form.cc b/src/form.cc index a69129b1..8781d815 100644 --- a/src/form.cc +++ b/src/form.cc @@ -271,7 +271,7 @@ static DilloHtmlInput *Html_get_radio_input(DilloHtml *html, const char *name) for (int idx = 0; idx < inputs->size(); idx++) { DilloHtmlInput *input = inputs->get(idx); if (input->type == DILLO_HTML_INPUT_RADIO && - input->name && !dStrcasecmp(input->name, name)) + input->name && !dStrAsciiCasecmp(input->name, name)) return input; } } @@ -318,9 +318,9 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) method = DILLO_HTML_METHOD_GET; if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "method"))) { - if (!dStrcasecmp(attrbuf, "post")) { + if (!dStrAsciiCasecmp(attrbuf, "post")) { method = DILLO_HTML_METHOD_POST; - } else if (dStrcasecmp(attrbuf, "get")) { + } else if (dStrAsciiCasecmp(attrbuf, "get")) { BUG_MSG("Unknown form submission method \"%s\"\n", attrbuf); } } @@ -333,7 +333,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) content_type = DILLO_HTML_ENC_URLENCODED; if ((method == DILLO_HTML_METHOD_POST) && ((attrbuf = a_Html_get_attr(html, tag, tagsize, "enctype")))) { - if (!dStrcasecmp(attrbuf, "multipart/form-data")) + if (!dStrAsciiCasecmp(attrbuf, "multipart/form-data")) content_type = DILLO_HTML_ENC_MULTIPART; } charset = NULL; @@ -343,9 +343,9 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize) char *ptr = first = dStrdup(attrbuf); while (ptr && !charset) { char *curr = dStrsep(&ptr, " ,"); - if (!dStrcasecmp(curr, "utf-8")) { + if (!dStrAsciiCasecmp(curr, "utf-8")) { charset = curr; - } else if (!dStrcasecmp(curr, "UNKNOWN")) { + } else if (!dStrAsciiCasecmp(curr, "UNKNOWN")) { /* defined to be whatever encoding the document is in */ charset = html->charset; } @@ -441,18 +441,18 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) init_str = NULL; inp_type = DILLO_HTML_INPUT_UNKNOWN; - if (!dStrcasecmp(type, "password")) { + if (!dStrAsciiCasecmp(type, "password")) { inp_type = DILLO_HTML_INPUT_PASSWORD; attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); resource = factory->createEntryResource (size, true, NULL); init_str = value; - } else if (!dStrcasecmp(type, "checkbox")) { + } else if (!dStrAsciiCasecmp(type, "checkbox")) { inp_type = DILLO_HTML_INPUT_CHECKBOX; resource = factory->createCheckButtonResource(false); init_val = (a_Html_get_attr(html, tag, tagsize, "checked") != NULL); init_str = (value) ? value : dStrdup("on"); - } else if (!dStrcasecmp(type, "radio")) { + } else if (!dStrAsciiCasecmp(type, "radio")) { inp_type = DILLO_HTML_INPUT_RADIO; RadioButtonResource *rb_r = NULL; DilloHtmlInput *input = Html_get_radio_input(html, name); @@ -461,22 +461,22 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) resource = factory->createRadioButtonResource(rb_r, false); init_val = (a_Html_get_attr(html, tag, tagsize, "checked") != NULL); init_str = value; - } else if (!dStrcasecmp(type, "hidden")) { + } else if (!dStrAsciiCasecmp(type, "hidden")) { inp_type = DILLO_HTML_INPUT_HIDDEN; init_str = value; int size = Html_input_get_size(html, NULL); resource = factory->createEntryResource(size, false, name); - } else if (!dStrcasecmp(type, "submit")) { + } else if (!dStrAsciiCasecmp(type, "submit")) { inp_type = DILLO_HTML_INPUT_SUBMIT; init_str = (value) ? value : dStrdup("submit"); resource = factory->createLabelButtonResource(init_str); // gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */ - } else if (!dStrcasecmp(type, "reset")) { + } else if (!dStrAsciiCasecmp(type, "reset")) { inp_type = DILLO_HTML_INPUT_RESET; init_str = (value) ? value : dStrdup("Reset"); resource = factory->createLabelButtonResource(init_str); // gtk_widget_set_sensitive(widget, FALSE); /* Until end of FORM! */ - } else if (!dStrcasecmp(type, "image")) { + } else if (!dStrAsciiCasecmp(type, "image")) { if (URL_FLAGS(html->base_url) & URL_SpamSafe) { /* Don't request the image; make a text submit button instead */ inp_type = DILLO_HTML_INPUT_SUBMIT; @@ -491,7 +491,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) embed = Html_input_image(html, tag, tagsize); init_str = value; } - } else if (!dStrcasecmp(type, "file")) { + } else if (!dStrAsciiCasecmp(type, "file")) { bool valid = true; if (html->InFlags & IN_FORM) { DilloHtmlForm *form = html->getCurrentForm(); @@ -512,7 +512,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) init_str = dStrdup("File selector"); resource = factory->createLabelButtonResource(init_str); } - } else if (!dStrcasecmp(type, "button")) { + } else if (!dStrAsciiCasecmp(type, "button")) { inp_type = DILLO_HTML_INPUT_BUTTON; if (value) { init_str = value; @@ -521,7 +521,7 @@ void Html_tag_open_input(DilloHtml *html, const char *tag, int tagsize) } else { /* Text input, which also is the default */ inp_type = DILLO_HTML_INPUT_TEXT; - if (*type && dStrcasecmp(type, "text")) + if (*type && dStrAsciiCasecmp(type, "text")) BUG_MSG("Unknown input type: \"%s\"\n", type); attrbuf = a_Html_get_attr(html, tag, tagsize, "size"); int size = Html_input_get_size(html, attrbuf); @@ -831,11 +831,11 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize) type = a_Html_get_attr_wdef(html, tag, tagsize, "type", ""); - if (!dStrcasecmp(type, "button")) { + if (!dStrAsciiCasecmp(type, "button")) { inp_type = DILLO_HTML_INPUT_BUTTON; - } else if (!dStrcasecmp(type, "reset")) { + } else if (!dStrAsciiCasecmp(type, "reset")) { inp_type = DILLO_HTML_INPUT_BUTTON_RESET; - } else if (!dStrcasecmp(type, "submit") || !*type) { + } else if (!dStrAsciiCasecmp(type, "submit") || !*type) { /* submit button is the default */ inp_type = DILLO_HTML_INPUT_BUTTON_SUBMIT; } else { @@ -1034,7 +1034,7 @@ Dstr *DilloHtmlForm::buildQueryData(DilloHtmlInput *active_submit) char *boundary = NULL; iconv_t char_encoder = (iconv_t) -1; - if (submit_charset && dStrcasecmp(submit_charset, "UTF-8")) { + if (submit_charset && dStrAsciiCasecmp(submit_charset, "UTF-8")) { char_encoder = iconv_open(submit_charset, "UTF-8"); if (char_encoder == (iconv_t) -1) { MSG_WARN("Cannot convert to character encoding '%s'\n", @@ -1308,8 +1308,8 @@ void DilloHtmlForm::filesInputMultipartAppend(Dstr* data, (void)a_Misc_get_content_type_from_data(file->str, file->len, &ctype); /* Heuristic: text/plain with ".htm[l]" extension -> text/html */ if ((ext = strrchr(filename, '.')) && - !dStrcasecmp(ctype, "text/plain") && - (!dStrcasecmp(ext, ".html") || !dStrcasecmp(ext, ".htm"))) { + !dStrAsciiCasecmp(ctype, "text/plain") && + (!dStrAsciiCasecmp(ext, ".html") || !dStrAsciiCasecmp(ext, ".htm"))){ ctype = "text/html"; } @@ -1474,7 +1474,7 @@ DilloHtmlInput *DilloHtmlForm::getRadioInput (const char *name) for (int idx = 0; idx < inputs->size(); idx++) { DilloHtmlInput *input = inputs->get(idx); if (input->type == DILLO_HTML_INPUT_RADIO && - input->name && !dStrcasecmp(input->name, name)) + input->name && !dStrAsciiCasecmp(input->name, name)) return input; } return NULL; diff --git a/src/html.cc b/src/html.cc index 9f3f048b..896aaab6 100644 --- a/src/html.cc +++ b/src/html.cc @@ -16,7 +16,7 @@ /*----------------------------------------------------------------------------- * Includes *---------------------------------------------------------------------------*/ -#include /* for isspace and tolower */ +#include /* for isspace */ #include /* for memcpy and memmove */ #include #include /* for sprintf */ @@ -311,16 +311,16 @@ void a_Html_tag_set_align_attr(DilloHtml *html, const char *tag, int tagsize) if ((align = a_Html_get_attr(html, tag, tagsize, "align"))) { TextAlignType textAlignType = TEXT_ALIGN_LEFT; - if (dStrcasecmp (align, "left") == 0) + if (dStrAsciiCasecmp (align, "left") == 0) textAlignType = TEXT_ALIGN_LEFT; - else if (dStrcasecmp (align, "right") == 0) + else if (dStrAsciiCasecmp (align, "right") == 0) textAlignType = TEXT_ALIGN_RIGHT; - else if (dStrcasecmp (align, "center") == 0) + else if (dStrAsciiCasecmp (align, "center") == 0) textAlignType = TEXT_ALIGN_CENTER; - else if (dStrcasecmp (align, "justify") == 0) + else if (dStrAsciiCasecmp (align, "justify") == 0) textAlignType = TEXT_ALIGN_JUSTIFY; #if 0 - else if (dStrcasecmp (align, "char") == 0) { + else if (dStrAsciiCasecmp (align, "char") == 0) { /* TODO: Actually not supported for

etc. */ v.textAlign = TEXT_ALIGN_STRING; if ((charattr = a_Html_get_attr(html, tag, tagsize, "char"))) { @@ -352,11 +352,11 @@ bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize) VAlignType valign; if ((attr = a_Html_get_attr(html, tag, tagsize, "valign"))) { - if (dStrcasecmp (attr, "top") == 0) + if (dStrAsciiCasecmp (attr, "top") == 0) valign = VALIGN_TOP; - else if (dStrcasecmp (attr, "bottom") == 0) + else if (dStrAsciiCasecmp (attr, "bottom") == 0) valign = VALIGN_BOTTOM; - else if (dStrcasecmp (attr, "baseline") == 0) + else if (dStrAsciiCasecmp (attr, "baseline") == 0) valign = VALIGN_BASELINE; else valign = VALIGN_MIDDLE; @@ -1240,7 +1240,7 @@ static bool Html_match_tag(const char *tagstr, char *tag, int tagsize) int i; for (i = 0; i < tagsize && tagstr[i] != '\0'; i++) { - if (tolower(tagstr[i]) != tolower(tag[i])) + if (D_ASCII_TOLOWER(tagstr[i]) != D_ASCII_TOLOWER(tag[i])) return false; } /* The test for '/' is for xml compatibility: "empty/>" will be matched. */ @@ -1530,18 +1530,18 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize) _MSG("New: {%s}\n", ntag); /* The default DT_NONE type is TagSoup */ - if (!dStrncasecmp(ntag, HTML_SGML_sig, strlen(HTML_SGML_sig))) { + if (!dStrnAsciiCasecmp(ntag, HTML_SGML_sig, strlen(HTML_SGML_sig))) { p = ntag + strlen(HTML_SGML_sig) + 1; if (!strncmp(p, HTML401, strlen(HTML401)) && - dStristr(p + strlen(HTML401), HTML401_url)) { + dStriAsciiStr(p + strlen(HTML401), HTML401_url)) { html->DocType = DT_HTML; html->DocTypeVersion = 4.01f; } else if (!strncmp(p, XHTML1, strlen(XHTML1)) && - dStristr(p + strlen(XHTML1), XHTML1_url)) { + dStriAsciiStr(p + strlen(XHTML1), XHTML1_url)) { html->DocType = DT_XHTML; html->DocTypeVersion = 1.0f; } else if (!strncmp(p, XHTML11, strlen(XHTML11)) && - dStristr(p + strlen(XHTML11), XHTML11_url)) { + dStriAsciiStr(p + strlen(XHTML11), XHTML11_url)) { html->DocType = DT_XHTML; html->DocTypeVersion = 1.1f; } else if (!strncmp(p, HTML40, strlen(HTML40))) { @@ -1554,7 +1554,7 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize) html->DocType = DT_HTML; html->DocTypeVersion = 2.0f; } - } else if (!dStrcasecmp(ntag, HTML5_sig)) { + } else if (!dStrAsciiCasecmp(ntag, HTML5_sig)) { BUG_MSG("Document follows HTML5 working draft; treating as HTML4.\n"); html->DocType = DT_HTML; html->DocTypeVersion = 5.0f; @@ -1687,11 +1687,11 @@ static void Html_tag_open_style(DilloHtml *html, const char *tag, int tagsize) if (!(attrbuf = a_Html_get_attr(html, tag, tagsize, "type"))) { BUG_MSG("type attribute is required for