1 #define main _main_disabled_
2 #include "trunk/darkhttpd.c"
6 test(const char *input
, const char *expected
)
8 char *tmp
= xstrdup(input
);
9 char *out
= make_safe_uri(tmp
);
11 if (expected
== NULL
) {
13 printf("PASS: \"%s\" is unsafe\n", input
);
15 printf("FAIL: \"%s\" is unsafe, but got \"%s\"\n",
19 printf("FAIL: \"%s\" should become \"%s\", got unsafe\n",
21 else if (strcmp(out
, expected
) == 0)
22 printf("PASS: \"%s\" => \"%s\"\n", input
, out
);
24 printf("FAIL: \"%s\" => \"%s\", expecting \"%s\"\n",
25 input
, out
, expected
);
29 static char const *tests
[] = {
40 "/abc/../def", "/def",
41 "/abc/../def/", "/def/",
42 "/abc/../def/..", "/",
43 "/abc/../def/../", "/",
44 "/abc/../def/../../", NULL
,
45 "/abc/../def/.././", "/",
46 "/abc/../def/.././../", NULL
,
47 "/a/b/c/../../d/", "/a/d/",
48 "/a/b/../../../c", NULL
,
49 /* don't forget consolidate_slashes */
50 "//a///b////c/////", "/a/b/c/",
57 const char **curr
= tests
;
59 while (curr
[0] != NULL
) {
60 test(curr
[0], curr
[1]);
66 /* vim:set tabstop=4 shiftwidth=4 expandtab tw=78: */