summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-12-29 12:10:46 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-12-29 12:39:17 +0100
commitb04ff42f1640a4dd67af043f08b62ac4ec96edc7 (patch)
tree01f8c6d3fb0f69d1dfb8d47b3cdd8f40c79e991e /tests
parent40ca906fa9f2f0e4e325432aff00433f2bb731bd (diff)
Fix normalization of slashes in filenames
All paths were canonicalized internally, which includes filtering sequences of slashes and converting backslashes to slashes. Furthermore, when unpacking files, filenames are sanity checked and rejected if they contain forward OR backward slashes. This is a problem on Unix-like systems, where files containing backslashes are a legitimate use case (*cough* SystemD *cough*). This patch removes the backslash conversion from the canonicalization and modifies the sanity check to reject backslashes only on Windows. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/canonicalize_name.c10
-rw-r--r--tests/filename_sane.c7
2 files changed, 9 insertions, 8 deletions
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",