Index: src/filename_scape.h
===================================================================
--- src/filename_scape.h	(revision 0)
+++ src/filename_scape.h	(revision 0)
@@ -0,0 +1,49 @@
+#ifndef __FILENAME_SCAPER__
+#define __FILENAME_SCAPER__
+
+/**
+ * @file   filename_scape.h
+ * @author Adenilson Cavalcanti <savagobr@yahoo.com>
+ * @date   Tue Oct 21 15:31:10 2008
+ *
+ * @brief  An auxiliary module to scape invalid characters from filename.
+ *
+ * This code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+
+ */
+
+static const char reserved_chars[] = { '/', '!', '?', ':', '*', '\\', '>', '<', '@' };
+static const int reserved_count = 9;
+static const char scaper = '_';
+
+static void filename_scape_characters(char *input)
+{
+
+	int i;
+
+	while (*input) {
+		for (i = 0; i < reserved_count; ++i)
+			if (*input ==  reserved_chars[i]) {
+				*input++ = scaper;
+				goto done;
+			}
+		++input;
+	done:
+		;
+	}
+
+}
+
+#endif
Index: src/file_sync.c
===================================================================
--- src/file_sync.c	(revision 3702)
+++ src/file_sync.c	(working copy)
@@ -19,6 +19,7 @@
  */
 
 #include "file_sync.h"
+#include "filename_scape.h"
 #include <opensync/file.h>
 #include <opensync/opensync-version.h>
 #include <assert.h>
@@ -143,8 +144,16 @@
 	char *buffer = NULL;
 	unsigned int size = 0;
 	
-	char *filename = g_strdup_printf ("%s/%s", dir->path, osync_change_get_uid(change));
-			
+	char *filename = NULL, *tmp = NULL;
+	if (!(tmp = strdup(osync_change_get_uid(change)))) {
+		osync_trace(TRACE_EXIT_ERROR, "%s", __func__);
+		return;
+	}
+	filename_scape_characters(tmp);
+
+	filename = g_strdup_printf ("%s/%s", dir->path, tmp);
+	free(tmp);
+
 	switch (osync_change_get_changetype(change)) {
 		case OSYNC_CHANGE_TYPE_DELETED:
 			if (!remove(filename) == 0) {
@@ -412,14 +421,20 @@
 	OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info);
 	OSyncFileDir *dir = osync_objtype_sink_get_userdata(sink);
 	
-	char *filename = NULL;
+	char *filename = NULL, *tmp;
 	
 	if (!osync_filesync_write(data, info, ctx, change)) {
 		osync_trace(TRACE_EXIT_ERROR, "%s", __func__);
 		return;
 	}
-	
-	filename = g_strdup_printf ("%s/%s", dir->path, osync_change_get_uid(change));
+	if (!(tmp = strdup(osync_change_get_uid(change)))) {
+		osync_trace(TRACE_EXIT_ERROR, "%s", __func__);
+		return;
+	}
+	filename_scape_characters(tmp);
+
+	filename = g_strdup_printf ("%s/%s", dir->path, tmp);
+	free(tmp);
 	char *hash = NULL;
 	
 	if (osync_change_get_changetype(change) != OSYNC_CHANGE_TYPE_DELETED) {

