From 92047114ac004cfed16eb15daa257cf84fe7ba36 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 24 Jul 2009 19:41:53 +0000 Subject: * Extend inventory name and description length checks to UpdateItem for mssql --- OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs index f68253a..d68ac39 100644 --- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs +++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs @@ -414,17 +414,20 @@ namespace OpenSim.Data.MSSQL @creationDate, @groupID, @groupOwned, @flags)"; string itemName = item.Name; + if (item.Name.Length > 64) { itemName = item.Name.Substring(0, 64); m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters"); } + string itemDesc = item.Description; if (item.Description.Length > 128) { itemDesc = item.Description.Substring(0, 128); m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters"); } + using (AutoClosingSqlCommand command = database.Query(sql)) { command.Parameters.Add(database.CreateParameter("inventoryID", item.ID)); @@ -499,6 +502,21 @@ namespace OpenSim.Data.MSSQL groupOwned = @groupOwned, flags = @flags WHERE inventoryID = @keyInventoryID"; + + string itemName = item.Name; + if (item.Name.Length > 64) + { + itemName = item.Name.Substring(0, 64); + m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters on update"); + } + + string itemDesc = item.Description; + if (item.Description.Length > 128) + { + itemDesc = item.Description.Substring(0, 128); + m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters on update"); + } + using (AutoClosingSqlCommand command = database.Query(sql)) { command.Parameters.Add(database.CreateParameter("inventoryID", item.ID)); @@ -506,8 +524,8 @@ namespace OpenSim.Data.MSSQL command.Parameters.Add(database.CreateParameter("assetType", item.AssetType)); command.Parameters.Add(database.CreateParameter("parentFolderID", item.Folder)); command.Parameters.Add(database.CreateParameter("avatarID", item.Owner)); - command.Parameters.Add(database.CreateParameter("inventoryName", item.Name)); - command.Parameters.Add(database.CreateParameter("inventoryDescription", item.Description)); + command.Parameters.Add(database.CreateParameter("inventoryName", itemName)); + command.Parameters.Add(database.CreateParameter("inventoryDescription", itemDesc)); command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions)); command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions)); command.Parameters.Add(database.CreateParameter("invType", item.InvType)); -- cgit v1.1