aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/fstree/canonicalize_name.c6
-rw-r--r--lib/fstree/filename_sane.c4
-rw-r--r--tests/canonicalize_name.c10
-rw-r--r--tests/filename_sane.c7
4 files changed, 14 insertions, 13 deletions
diff --git a/lib/fstree/canonicalize_name.c b/lib/fstree/canonicalize_name.c
index f35307f..7fbd5a7 100644
--- a/lib/fstree/canonicalize_name.c
+++ b/lib/fstree/canonicalize_name.c
@@ -11,12 +11,12 @@ static void normalize_slashes(char *filename)
{
char *dst = filename, *src = filename;
- while (*src == '/' || *src == '\\')
+ while (*src == '/')
++src;
while (*src != '\0') {
- if (*src == '/' || *src == '\\') {
- while (*src == '/' || *src == '\\')
+ if (*src == '/') {
+ while (*src == '/')
++src;
if (*src == '\0')
break;
diff --git a/lib/fstree/filename_sane.c b/lib/fstree/filename_sane.c
index b0f8c90..91c15da 100644
--- a/lib/fstree/filename_sane.c
+++ b/lib/fstree/filename_sane.c
@@ -57,7 +57,7 @@ bool is_filename_sane(const char *name, bool check_os_specific)
return false;
while (*name != '\0') {
- if (*name == '/' || *name == '\\')
+ if (*name == '/')
return false;
#if defined(_WIN32) || defined(__WINDOWS__) || defined(TEST_WIN32)
@@ -66,7 +66,7 @@ bool is_filename_sane(const char *name, bool check_os_specific)
return false;
if (*name == '"' || *name == '|' || *name == '?')
return false;
- if (*name == '*' || *name <= 31)
+ if (*name == '*' || *name == '\\' || *name <= 31)
return false;
}
#endif
diff --git a/tests/canonicalize_name.c b/tests/canonicalize_name.c
index 679cd06..2ab73a0 100644
--- a/tests/canonicalize_name.c
+++ b/tests/canonicalize_name.c
@@ -14,14 +14,14 @@ static const struct {
} must_work[] = {
{ "", "" },
{ "/", "" },
- { "\\", "" },
+ { "\\", "\\" },
{ "///", "" },
- { "\\\\\\", "" },
- { "/\\//\\\\/", "" },
+ { "\\\\\\", "\\\\\\" },
+ { "/\\//\\\\/", "\\/\\\\" },
{ "foo/bar/test", "foo/bar/test" },
- { "foo\\bar\\test", "foo/bar/test" },
+ { "foo\\bar\\test", "foo\\bar\\test" },
{ "/foo/bar/test/", "foo/bar/test" },
- { "\\foo\\bar\\test\\", "foo/bar/test" },
+ { "\\foo\\bar\\test\\", "\\foo\\bar\\test\\" },
{ "///foo//bar//test///", "foo/bar/test" },
{ "./foo/././bar/test/./.", "foo/bar/test" },
{ "./foo/././", "foo" },
diff --git a/tests/filename_sane.c b/tests/filename_sane.c
index 3c1fd4f..86270b3 100644
--- a/tests/filename_sane.c
+++ b/tests/filename_sane.c
@@ -11,6 +11,9 @@
static const char *must_work[] = {
"foobar",
"test.txt",
+#if !defined(_WIN32) && !defined(__WINDOWS__) && !defined(TEST_WIN32)
+ "\\foo", "foo\\", "foo\\bar",
+#endif
NULL,
};
@@ -18,16 +21,14 @@ static const char *must_not_work[] = {
".",
"..",
"/foo",
- "\\foo",
"foo/",
- "foo\\",
"foo/bar",
- "foo\\bar",
NULL,
};
static const char *must_not_work_here[] = {
#if defined(_WIN32) || defined(__WINDOWS__) || defined(TEST_WIN32)
+ "\\foo", "foo\\", "foo\\bar",
"fo<o", "fo>o", "fo:o", "fo\"o",
"fo|o", "fo?o", "fo*o", "fo\ro",
"CON", "PRN", "AUX", "NUL",