| 73 | }; |
| 74 | |
| 75 | char *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 | } |
searching dependent graphs…