MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_url_decode

Function acl_url_decode

lib_acl/src/code/acl_urlcode.c:75–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73};
74
75char *acl_url_decode(const char *str, ACL_DBUF_POOL *dbuf)
76{
77 char *tmp;
78 int i, len, pos = 0;
79
80 len = (int) strlen(str);
81 if (dbuf != NULL)
82 tmp = (char*) acl_dbuf_pool_alloc(dbuf, len + 1);
83 else
84 tmp = (char*) acl_mymalloc(len + 1);
85
86 for (i = 0; i < len; i++) {
87 /* If we found a '%' character, then the next two are
88 * the character hexa code. Converting a hexadecimal
89 * code to their decimal is easy: The first character
90 * needs to be multiplied by 16 ( << 4 ), and the
91 * another one we just get the value from hextable variable
92 */
93 /*
94 if (str[i] == '+')
95 tmp[pos] = ' ';
96 else */
97 if (str[i] != '%')
98 tmp[pos] = str[i];
99 else if (i + 2 >= len) { /* check boundary */
100 tmp[pos++] = '%'; /* keep it */
101 if (++i >= len)
102 break;
103 tmp[pos] = str[i];
104 break;
105 } else if (isalnum((int) str[i + 1]) && isalnum((int) str[i + 2])) {
106 tmp[pos] = (dec_tab[(unsigned char) str[i + 1]] << 4)
107 + dec_tab[(unsigned char) str[i + 2]];
108 i += 2;
109 } else
110 tmp[pos] = str[i];
111
112 pos++;
113 }
114
115 tmp[pos] = '\0';
116 return tmp;
117}

Callers 6

mainFunction · 0.85
test_urlcodeFunction · 0.85
load_paramMethod · 0.85
acl_foreachFunction · 0.85
acl_foreachFunction · 0.85
string.cppFile · 0.85

Calls 1

acl_dbuf_pool_allocFunction · 0.85

Tested by 1

test_urlcodeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…