diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index a535633f4b..0a2e2e4491 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -254,10 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); - // Escape back characters - newFolderName = newFolderName.Replace("/", "/"); - newFolderName = newFolderName.Replace("&", "&"); - + newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName); UUID newFolderId = UUID.Random(); // Asset type has to be Unknown here rather than Folder, otherwise the created folder can't be @@ -338,10 +335,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// All the inventory nodes (items and folders) loaded so far protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder) { - // Escape back characters -// filePath = filePath.Replace("/", "/"); -// filePath = filePath.Replace("&", "&"); - InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); // Don't use the item ID that's in the file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 78032d1453..247cee41c8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs @@ -295,5 +295,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return sb.ToString(); } + + /// + /// Escape an archive path. + /// + /// This has to be done differently from human paths because we can't leave in any "/" characters (due to + /// problems if the archive is built from or extracted to a filesystem + /// + /// + public static string EscapeArchivePath(string path) + { + // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). + return path.Replace("&", "&").Replace("/", "/"); + } + + /// + /// Unescape an archive path. + /// + /// + /// + public static string UnescapeArchivePath(string path) + { + return path.Replace("/", "/").Replace("&", "&"); + } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 6c371988be..bbb49f6108 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -362,13 +362,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static string CreateArchiveFolderName(string name, UUID id) { - // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). - name = name.Replace("&", "&"); - name = name.Replace("/", "/"); - return string.Format( "{0}{1}{2}/", - name, + InventoryArchiveUtils.EscapeArchivePath(name), ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, id); } @@ -381,12 +377,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public static string CreateArchiveItemName(string name, UUID id) { - name = name.Replace("&", "&"); - name = name.Replace("/", "/"); - return string.Format( "{0}{1}{2}.xml", - name, + InventoryArchiveUtils.EscapeArchivePath(name), ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, id); }