| 240 | } |
| 241 | |
| 242 | int main_path_decoding_tests(int argc, char** argv) { |
| 243 | htp_cfg_t *cfg = htp_config_create(); |
| 244 | htp_connp_t *connp = htp_connp_create(cfg); |
| 245 | htp_tx_t *tx = htp_tx_create(connp); |
| 246 | char *str; |
| 247 | bstr *path = NULL; |
| 248 | |
| 249 | // |
| 250 | path = bstr_dup_c("/One\\two///ThRee%2ffive%5csix/se%xxven"); |
| 251 | cfg->path_case_insensitive = 1; |
| 252 | |
| 253 | str = bstr_util_strdup_to_c(path); |
| 254 | printf("Before: %s\n", str); |
| 255 | free(str); |
| 256 | htp_decode_path_inplace(cfg, tx, path); |
| 257 | str = bstr_util_strdup_to_c(path); |
| 258 | printf("After: %s\n\n", str); |
| 259 | free(str); |
| 260 | bstr_free(path); |
| 261 | |
| 262 | // |
| 263 | path = bstr_dup_c("/One\\two///ThRee%2ffive%5csix/se%xxven"); |
| 264 | cfg->path_case_insensitive = 1; |
| 265 | cfg->path_compress_separators = 1; |
| 266 | |
| 267 | str = bstr_util_strdup_to_c(path); |
| 268 | printf("Before: %s\n", str); |
| 269 | free(str); |
| 270 | htp_decode_path_inplace(cfg, tx, path); |
| 271 | str = bstr_util_strdup_to_c(path); |
| 272 | printf("After: %s\n\n", str); |
| 273 | free(str); |
| 274 | bstr_free(path); |
| 275 | |
| 276 | // |
| 277 | path = bstr_dup_c("/One\\two///ThRee%2ffive%5csix/se%xxven"); |
| 278 | cfg->path_case_insensitive = 1; |
| 279 | cfg->path_compress_separators = 1; |
| 280 | cfg->path_backslash_separators = 1; |
| 281 | |
| 282 | str = bstr_util_strdup_to_c(path); |
| 283 | printf("Before: %s\n", str); |
| 284 | free(str); |
| 285 | htp_decode_path_inplace(cfg, tx, path); |
| 286 | str = bstr_util_strdup_to_c(path); |
| 287 | printf("After: %s\n\n", str); |
| 288 | free(str); |
| 289 | bstr_free(path); |
| 290 | |
| 291 | // |
| 292 | path = bstr_dup_c("/One\\two///ThRee%2ffive%5csix/se%xxven"); |
| 293 | cfg->path_case_insensitive = 1; |
| 294 | cfg->path_compress_separators = 1; |
| 295 | cfg->path_backslash_separators = 1; |
| 296 | cfg->path_encoded_separators_decode = 1; |
| 297 | |
| 298 | str = bstr_util_strdup_to_c(path); |
| 299 | printf("Before: %s\n", str); |
nothing calls this directly
no test coverage detected