csync_exclude: Don't ignore invalid char client side (#3736)
authorOlivier Goffart <ogoffart@woboq.com>
Thu, 22 Oct 2015 10:31:52 +0000 (12:31 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Thu, 22 Oct 2015 10:32:53 +0000 (12:32 +0200)
If the server does not support it, then the server will reply with an error

csync/src/csync_exclude.c

index 9e1c80bccf41f749b22d26679571af1dcda09aba..375425106808b9e4594e6e24b7a6c84a4d235494 100644 (file)
@@ -171,7 +171,6 @@ bool csync_is_windows_reserved_word(const char* filename) {
 
 static CSYNC_EXCLUDE_TYPE _csync_excluded_common(c_strlist_t *excludes, const char *path, int filetype, bool check_leading_dirs) {
     size_t i = 0;
-    const char *p = NULL;
     const char *bname = NULL;
     size_t blen = 0;
     char *conflict = NULL;
@@ -179,22 +178,6 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(c_strlist_t *excludes, const ch
     CSYNC_EXCLUDE_TYPE match = CSYNC_NOT_EXCLUDED;
     CSYNC_EXCLUDE_TYPE type  = CSYNC_NOT_EXCLUDED;
 
-      for (p = path; *p; p++) {
-        switch (*p) {
-          case '\\':
-          case ':':
-          case '?':
-          case '*':
-          case '"':
-          case '>':
-          case '<':
-          case '|':
-            return CSYNC_FILE_EXCLUDE_INVALID_CHAR;
-          default:
-            break;
-        }
-      }
-
     /* split up the path */
     bname = strrchr(path, '/');
     if (bname) {
@@ -217,7 +200,7 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(c_strlist_t *excludes, const ch
         goto out;
     }
 
-  #ifdef _WIN32
+#ifdef _WIN32
     // Windows cannot sync files ending in spaces (#2176). It also cannot
     // distinguish files ending in '.' from files without an ending,
     // as '.' is a separator that is not stored internally, so let's
@@ -231,7 +214,26 @@ static CSYNC_EXCLUDE_TYPE _csync_excluded_common(c_strlist_t *excludes, const ch
       match = CSYNC_FILE_EXCLUDE_INVALID_CHAR;
       goto out;
     }
-  #endif
+
+    // Filter out characters not allowed in a filename on windows
+    const char *p = NULL;
+    for (p = path; *p; p++) {
+        switch (*p) {
+        case '\\':
+        case ':':
+        case '?':
+        case '*':
+        case '"':
+        case '>':
+        case '<':
+        case '|':
+            match = CSYNC_FILE_EXCLUDE_INVALID_CHAR;
+            goto out;
+        default:
+            break;
+        }
+    }
+#endif
 
     rc = csync_fnmatch(".owncloudsync.log*", bname, 0);
     if (rc == 0) {