summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-06-02 17:50:45 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-06-02 17:50:45 +0200
commit0a6420ee62b9a58d55812a206df2bde41fb64598 (patch)
treed7466ebce11a615a11c13e9937d9f8c0473455a7
parent61d4870dc9c7a0d78d9ae54d95b41d383770a522 (diff)
downloadcurl-bagder/dedotdot-fix.tar.gz
dedotdot: fixed output for ".." and "." only inputbagder/dedotdot-fix
Found when updating test 1395, which I did to increase test coverage of this source file...
-rw-r--r--lib/dotdot.c3
-rw-r--r--tests/unit/unit1395.c9
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/dotdot.c b/lib/dotdot.c
index ea7c8a04f..20603bcab 100644
--- a/lib/dotdot.c
+++ b/lib/dotdot.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -147,6 +147,7 @@ char *Curl_dedotdotify(const char *input)
else if(!strcmp(".", clone) || !strcmp("..", clone)) {
*clone=0;
+ *out=0;
}
else {
diff --git a/tests/unit/unit1395.c b/tests/unit/unit1395.c
index ba8e14f45..13ea97bc4 100644
--- a/tests/unit/unit1395.c
+++ b/tests/unit/unit1395.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -65,6 +65,13 @@ UNITTEST_START
{ "/", "/" },
{ "", "" },
{ "/.../", "/.../" },
+ { "./moo", "moo" },
+ { "../moo", "moo" },
+ { "/.", "/" },
+ { "/..", "/" },
+ { "/moo/..", "/" },
+ { "..", "" },
+ { ".", "" },
};
for(i=0; i < sizeof(pairs)/sizeof(pairs[0]); i++) {