Index: funcs/func_curl.c =================================================================== --- funcs/func_curl.c (revision 288712) +++ funcs/func_curl.c (working copy) @@ -91,6 +91,12 @@ OT_ENUM, }; +enum hashcompat { + HASHCOMPAT_NO = 0, + HASHCOMPAT_YES, + HASHCOMPAT_LEGACY, +}; + static int parse_curlopt_key(const char *name, CURLoption *key, enum optiontype *ot) { if (!strcasecmp(name, "header")) { @@ -153,7 +159,7 @@ *ot = OT_BOOLEAN; } else if (!strcasecmp(name, "hashcompat")) { *key = CURLOPT_SPECIAL_HASHCOMPAT; - *ot = OT_BOOLEAN; + *ot = OT_ENUM; } else { return -1; } @@ -242,6 +248,8 @@ if ((new = ast_calloc(1, sizeof(*new)))) { new->value = (void *)ptype; } + } else if (key == CURLOPT_SPECIAL_HASHCOMPAT) { + new->value = (void *) (long) (!strcasecmp(value, "legacy") ? HASHCOMPAT_LEGACY : ast_true(value) ? HASHCOMPAT_YES : HASHCOMPAT_NO); } else { /* Highly unlikely */ goto yuck; @@ -333,52 +341,46 @@ ast_str_set(bufstr, 0, "%s", (char *) cur->value); } } else if (key == CURLOPT_PROXYTYPE) { + const char *strval = "unknown"; if (0) { #if CURLVERSION_ATLEAST(7,15,2) } else if ((long)cur->value == CURLPROXY_SOCKS4) { - if (buf) { - ast_copy_string(buf, "socks4", len); - } else { - ast_str_set(bufstr, 0, "socks4"); - } + strval = "socks4"; #endif #if CURLVERSION_ATLEAST(7,18,0) } else if ((long)cur->value == CURLPROXY_SOCKS4A) { - if (buf) { - ast_copy_string(buf, "socks4a", len); - } else { - ast_str_set(bufstr, 0, "socks4a"); - } + strval = "socks4a"; #endif } else if ((long)cur->value == CURLPROXY_SOCKS5) { - if (buf) { - ast_copy_string(buf, "socks5", len); - } else { - ast_str_set(bufstr, 0, "socks5"); - } + strval = "socks5"; #if CURLVERSION_ATLEAST(7,18,0) } else if ((long)cur->value == CURLPROXY_SOCKS5_HOSTNAME) { - if (buf) { - ast_copy_string(buf, "socks5hostname", len); - } else { - ast_str_set(bufstr, 0, "socks5hostname"); - } + strval = "socks5hostname"; #endif #if CURLVERSION_ATLEAST(7,10,0) } else if ((long)cur->value == CURLPROXY_HTTP) { - if (buf) { - ast_copy_string(buf, "http", len); - } else { - ast_str_set(bufstr, 0, "http"); - } + strval = "http"; #endif + } + if (buf) { + ast_copy_string(buf, strval, len); } else { - if (buf) { - ast_copy_string(buf, "unknown", len); - } else { - ast_str_set(bufstr, 0, "unknown"); - } + ast_str_set(bufstr, 0, "%s", strval); } + } else if (key == CURLOPT_SPECIAL_HASHCOMPAT) { + const char *strval = "unknown"; + if ((long) cur->value == HASHCOMPAT_LEGACY) { + strval = "legacy"; + } else if ((long) cur->value == HASHCOMPAT_YES) { + strval = "yes"; + } else if ((long) cur->value == HASHCOMPAT_NO) { + strval = "no"; + } + if (buf) { + ast_copy_string(buf, strval, len); + } else { + ast_str_set(bufstr, 0, "%s", strval); + } } break; } @@ -482,7 +484,7 @@ AST_LIST_LOCK(&global_curl_info); AST_LIST_TRAVERSE(&global_curl_info, cur, list) { if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) { - hashcompat = (cur->value != NULL) ? 1 : 0; + hashcompat = (long) cur->value; } else { curl_easy_setopt(*curl, cur->key, cur->value); } @@ -531,6 +533,12 @@ int rowcount = 0; while ((piece = strsep(&remainder, "&"))) { char *name = strsep(&piece, "="); + if (hashcompat == HASHCOMPAT_LEGACY) { + char *plus; + while ((plus = strchr(piece, '+')) || (plus = strchr(name, '+'))) { + *plus = ' '; + } + } ast_uri_decode(piece); ast_uri_decode(name); ast_str_append(&fields, 0, "%s%s", rowcount ? "," : "", name); @@ -605,6 +613,7 @@ " userpwd - A : to use for authentication\n" " ssl_verifypeer - Whether to verify the peer certificate (boolean)\n" " hashcompat - Result data will be compatible for use with HASH()\n" +" - if value is \"legacy\", will translate '+' to ' '\n" "", .read = acf_curlopt_read, .read2 = acf_curlopt_read2,