diff --git a/tools/data_export/export_remote.xml b/tools/data_export/export_remote.xml
index ef5450cc55d9..7840d70ae64a 100644
--- a/tools/data_export/export_remote.xml
+++ b/tools/data_export/export_remote.xml
@@ -18,15 +18,35 @@ python '$__tool_directory__/export_remote.py'
#import json
#from galaxy.util import filesystem_safe_string
#if $export_type.export_type_selector == "datasets_auto":
-#set $fileconfig = json.dumps($export_type.infiles.serialize(invalid_chars=tuple(str($invalid_chars))))
+ #if $invalid_chars=="space":
+ #set $fileconfig = json.dumps($export_type.infiles.serialize(invalid_chars=tuple(str(" "))))
+ #else:
+ #set $fileconfig = json.dumps($export_type.infiles.serialize(invalid_chars=tuple(str($invalid_chars))))
+ #end if
#else if $export_type.export_type_selector == "collection_auto":
-#set $fileconfig = json.dumps($export_type.incollection.serialize(invalid_chars=tuple(str($invalid_chars)), include_collection_name=bool($export_type.include_collection_name)))
+ #set $fileconfig = json.dumps($export_type.incollection.serialize(invalid_chars=tuple(str($invalid_chars)), include_collection_name=bool($export_type.include_collection_name)))
+
+ #if $invalid_chars=="space":
+ #set $fileconfig = json.dumps($export_type.incollection.serialize(invalid_chars=tuple(str(" ")), include_collection_name=bool($export_type.include_collection_name)))
+ #else:
+ #set $fileconfig = json.dumps($export_type.incollection.serialize(invalid_chars=tuple(str($invalid_chars)), include_collection_name=bool($export_type.include_collection_name)))
+ #end if
+
#else
-#set $fileconfig = [d['infile'].serialize() for d in $export_type.datasets]
-#for $i, $dataset in enumerate($export_type.datasets):
- #silent $fileconfig[$i]['staging_path'] = filesystem_safe_string(str(dataset["name"]), 255, invalid_chars=())
-#end for
-#silent fileconfig = json.dumps($fileconfig)
+
+ #set $fileconfig = [d['infile'].serialize() for d in $export_type.datasets]
+ #if $invalid_chars=="space":
+ #for $i, $dataset in enumerate($export_type.datasets):
+ #silent $fileconfig[$i]['staging_path'] = filesystem_safe_string(str(dataset["name"]), 255, invalid_chars=[str(" ")])
+ #end for
+ #else:
+ #for $i, $dataset in enumerate($export_type.datasets):
+ #silent $fileconfig[$i]['staging_path'] = filesystem_safe_string(str(dataset["name"]), 255, invalid_chars=[str($invalid_chars)])
+ #end for
+ #end if
+
+ #silent fileconfig = json.dumps($fileconfig)
+
#end if
$fileconfig
@@ -61,6 +81,7 @@ $fileconfig
+