aboutsummaryrefslogtreecommitdiffstats
path: root/funcs/func_curl.c
diff options
context:
space:
mode:
authormnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-24 18:59:22 +0000
committermnicholson <mnicholson@f38db490-d61c-443f-a65b-d21fe96a405b>2011-01-24 18:59:22 +0000
commit9dd80bbb536876176a1d99791642e6e3abad896f (patch)
tree9e6c6ce3c4de14d886a8c131a7621a792d457728 /funcs/func_curl.c
parentdf02d8f6007ebf24bac7970640a4b59f4f09d738 (diff)
According to section 19.1.2 of RFC 3261:
For each component, the set of valid BNF expansions defines exactly which characters may appear unescaped. All other characters MUST be escaped. This patch modifies ast_uri_encode() to encode strings in line with this recommendation. This patch also adds an ast_escape_quoted() function which escapes '"' and '\' characters in quoted strings in accordance with section 25.1 of RFC 3261. The ast_uri_encode() function has also been modified to take an ast_flags struct describing the set of rules it should use when escaping characters to allow for it to escape SIP URIs in addition to HTTP URIs and other types of URIs or variations of those two URI types in the future. The ast_uri_decode() function has also been modified to accept an ast_flags struct describing the set of rules to use when decoding to enable decoding '+' as ' ' in legacy http URLs. The unit tests for these functions have also been updated. ABE-2705 Review: https://reviewboard.asterisk.org/r/1081/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@303509 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_curl.c')
-rw-r--r--funcs/func_curl.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index 0795944ca..e5784652f 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -658,20 +658,12 @@ static int acf_curl_helper(struct ast_channel *chan, const char *cmd, char *info
* a literal plus-sign, we don't want to translate that to a
* space. */
if (hashcompat == HASHCOMPAT_LEGACY) {
- int i;
- for (i = 0; name[i]; i++) {
- if (name[i] == '+') {
- name[i] = ' ';
- }
- }
- for (i = 0; piece[i]; i++) {
- if (piece[i] == '+') {
- piece[i] = ' ';
- }
- }
+ ast_uri_decode(piece, ast_uri_http_legacy);
+ ast_uri_decode(name, ast_uri_http_legacy);
+ } else {
+ ast_uri_decode(piece, ast_uri_http);
+ ast_uri_decode(name, ast_uri_http);
}
- ast_uri_decode(piece);
- ast_uri_decode(name);
ast_str_append(&fields, 0, "%s%s", rowcount ? "," : "", name);
ast_str_append(&values, 0, "%s%s", rowcount ? "," : "", piece);
rowcount++;