1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "curlcheck.h"
28 static CURLcode unit_setup(void)
33 static void unit_stop(void)
47 const struct dotdot pairs[] = {
48 { "/a/b/c/./../../g", "/a/g" },
49 { "mid/content=5/../6", "mid/6" },
50 { "/hello/../moo", "/moo" },
56 { "/1/./../2", "/2" },
57 { "/hello/1/./../2", "/hello/2" },
58 { "test/this", "test/this" },
59 { "test/this/../now", "test/now" },
60 { "/1../moo../foo", "/1../moo../foo"},
61 { "/../../moo", "/moo"},
62 { "/../../moo?andnot/../yay", "/moo?andnot/../yay"},
63 { "/123?foo=/./&bar=/../", "/123?foo=/./&bar=/../"},
64 { "/../moo/..?what", "/?what" },
70 for(i=0; i < sizeof(pairs)/sizeof(pairs[0]); i++) {
71 char *out = Curl_dedotdotify((char *)pairs[i].input);
72 abort_unless(out != NULL, "returned NULL!");
74 if(strcmp(out, pairs[i].output)) {
75 fprintf(stderr, "Test %d: '%s' gave '%s' instead of '%s'\n",
76 i, pairs[i].input, out, pairs[i].output);
77 fail("Test case output mismatched");
81 fprintf(stderr, "Test %d: OK\n", i);
85 fail_if(fails, "output mismatched");