diff options
author | Justin Clark-Casey (justincc) | 2009-11-09 17:34:07 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-11-09 17:34:07 +0000 |
commit | 716f70cd31e6126f8752cb8843cca104ad91d8f6 (patch) | |
tree | 616c9d52b4bfe4ce1c4383707b9dc8f397eb9603 /OpenSim | |
parent | minor: correct slightly over-enthusiastic load iar logging message (diff) | |
download | opensim-SC_OLD-716f70cd31e6126f8752cb8843cca104ad91d8f6.zip opensim-SC_OLD-716f70cd31e6126f8752cb8843cca104ad91d8f6.tar.gz opensim-SC_OLD-716f70cd31e6126f8752cb8843cca104ad91d8f6.tar.bz2 opensim-SC_OLD-716f70cd31e6126f8752cb8843cca104ad91d8f6.tar.xz |
refactor out iar escaping
Diffstat (limited to 'OpenSim')
3 files changed, 26 insertions, 17 deletions
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 | |||
254 | 254 | ||
255 | string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | 255 | string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); |
256 | 256 | ||
257 | // Escape back characters | 257 | newFolderName = InventoryArchiveUtils.UnescapeArchivePath(newFolderName); |
258 | newFolderName = newFolderName.Replace("/", "/"); | ||
259 | newFolderName = newFolderName.Replace("&", "&"); | ||
260 | |||
261 | UUID newFolderId = UUID.Random(); | 258 | UUID newFolderId = UUID.Random(); |
262 | 259 | ||
263 | // Asset type has to be Unknown here rather than Folder, otherwise the created folder can't be | 260 | // 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 | |||
338 | /// <param name="nodesLoaded">All the inventory nodes (items and folders) loaded so far</param> | 335 | /// <param name="nodesLoaded">All the inventory nodes (items and folders) loaded so far</param> |
339 | protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder) | 336 | protected InventoryItemBase LoadItem(byte[] data, InventoryFolderBase loadFolder) |
340 | { | 337 | { |
341 | // Escape back characters | ||
342 | // filePath = filePath.Replace("/", "/"); | ||
343 | // filePath = filePath.Replace("&", "&"); | ||
344 | |||
345 | InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); | 338 | InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data); |
346 | 339 | ||
347 | // Don't use the item ID that's in the file | 340 | // 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 | |||
295 | 295 | ||
296 | return sb.ToString(); | 296 | return sb.ToString(); |
297 | } | 297 | } |
298 | |||
299 | /// <summary> | ||
300 | /// Escape an archive path. | ||
301 | /// </summary> | ||
302 | /// This has to be done differently from human paths because we can't leave in any "/" characters (due to | ||
303 | /// problems if the archive is built from or extracted to a filesystem | ||
304 | /// <param name="path"></param> | ||
305 | /// <returns></returns> | ||
306 | public static string EscapeArchivePath(string path) | ||
307 | { | ||
308 | // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). | ||
309 | return path.Replace("&", "&").Replace("/", "/"); | ||
310 | } | ||
311 | |||
312 | /// <summary> | ||
313 | /// Unescape an archive path. | ||
314 | /// </summary> | ||
315 | /// <param name="path"></param> | ||
316 | /// <returns></returns> | ||
317 | public static string UnescapeArchivePath(string path) | ||
318 | { | ||
319 | return path.Replace("/", "/").Replace("&", "&"); | ||
320 | } | ||
298 | } | 321 | } |
299 | } \ No newline at end of file | 322 | } \ 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 | |||
362 | /// <returns></returns> | 362 | /// <returns></returns> |
363 | public static string CreateArchiveFolderName(string name, UUID id) | 363 | public static string CreateArchiveFolderName(string name, UUID id) |
364 | { | 364 | { |
365 | // Only encode ampersands (for escaping anything) and / (since this is used as general dir separator). | ||
366 | name = name.Replace("&", "&"); | ||
367 | name = name.Replace("/", "/"); | ||
368 | |||
369 | return string.Format( | 365 | return string.Format( |
370 | "{0}{1}{2}/", | 366 | "{0}{1}{2}/", |
371 | name, | 367 | InventoryArchiveUtils.EscapeArchivePath(name), |
372 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 368 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
373 | id); | 369 | id); |
374 | } | 370 | } |
@@ -381,12 +377,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
381 | /// <returns></returns> | 377 | /// <returns></returns> |
382 | public static string CreateArchiveItemName(string name, UUID id) | 378 | public static string CreateArchiveItemName(string name, UUID id) |
383 | { | 379 | { |
384 | name = name.Replace("&", "&"); | ||
385 | name = name.Replace("/", "/"); | ||
386 | |||
387 | return string.Format( | 380 | return string.Format( |
388 | "{0}{1}{2}.xml", | 381 | "{0}{1}{2}.xml", |
389 | name, | 382 | InventoryArchiveUtils.EscapeArchivePath(name), |
390 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 383 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
391 | id); | 384 | id); |
392 | } | 385 | } |