From 345ddcd0d82b15afa790ede4c1e8d93361a0d405 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Nov 2009 18:53:25 +0000 Subject: * Escape / character when saving items and folders in an iar so that the loader doesn't barf --- .../Inventory/Archiver/InventoryArchiveReadRequest.cs | 13 +++++++++++-- .../Inventory/Archiver/InventoryArchiveWriteRequest.cs | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f761bf0..7abaac0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -161,14 +161,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver failedAssetRestores++; } else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) - { + { InventoryFolderBase foundFolder = ReplicateArchivePathToUserInventory( filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, rootDestinationFolder, foldersCreated, nodesLoaded); if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) - { + { + // 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 @@ -289,6 +293,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); + + // Escape back characters + newFolderName = newFolderName.Replace("/", "/"); + newFolderName = newFolderName.Replace("&", "&"); + UUID newFolderId = UUID.Random(); // Asset type has to be Unknown here rather than Folder, otherwise the created folder can't be diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 499c552..af0b72f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -394,6 +394,10 @@ 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, @@ -409,6 +413,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, -- cgit v1.1