From 716f70cd31e6126f8752cb8843cca104ad91d8f6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 9 Nov 2009 17:34:07 +0000
Subject: refactor out iar escaping
---
.../Archiver/InventoryArchiveReadRequest.cs | 9 +--------
.../Inventory/Archiver/InventoryArchiveUtils.cs | 23 ++++++++++++++++++++++
.../Archiver/InventoryArchiveWriteRequest.cs | 11 ++---------
3 files changed, 26 insertions(+), 17 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index a535633..0a2e2e4 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 78032d1..247cee4 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 6c37198..bbb49f6 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);
}
--
cgit v1.1