From 575935ded08164739d52ae9f111c6c3f8e308c50 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 1 Mar 2019 09:33:55 +0100 Subject: [PATCH] Windows: Forbid chars 0-31 in filenames #6987 --- src/csync/csync_exclude.cpp | 6 +++++- test/testexcludedfiles.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 8233a6b1f..902dffc76 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -187,7 +187,11 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(const QString &path, bool exclu // Filter out characters not allowed in a filename on windows for (auto p : path) { - switch (p.unicode()) { + const ushort c = p.unicode(); + if (c < 32) { + return CSYNC_FILE_EXCLUDE_INVALID_CHAR; + } + switch (c) { case '\\': case ':': case '?': diff --git a/test/testexcludedfiles.cpp b/test/testexcludedfiles.cpp index cb6b3c1a2..f00683e88 100644 --- a/test/testexcludedfiles.cpp +++ b/test/testexcludedfiles.cpp @@ -193,10 +193,10 @@ private slots: #ifdef _WIN32 QCOMPARE(check_file_full("file_trailing_space "), CSYNC_FILE_EXCLUDE_TRAILING_SPACE); - QCOMPARE(check_file_full("file_trailing_dot."), CSYNC_FILE_EXCLUDE_INVALID_CHAR); QCOMPARE(check_file_full("AUX"), CSYNC_FILE_EXCLUDE_INVALID_CHAR); QCOMPARE(check_file_full("file_invalid_char<"), CSYNC_FILE_EXCLUDE_INVALID_CHAR); + QCOMPARE(check_file_full("file_invalid_char\n"), CSYNC_FILE_EXCLUDE_INVALID_CHAR); #endif /* ? character */ -- 2.39.5