From 93a9ed2a6d5f6005ae213e2e91f1c79e2fd7f775 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Tue, 22 Apr 2014 12:04:06 +0300 Subject: Changed the maximum asset name and description lengths to constants. Also, pre-truncate the description of dynamic textures. --- OpenSim/Data/MSSQL/MSSQLAssetData.cs | 8 ++++---- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 ++++---- OpenSim/Data/MySQL/MySQLXAssetData.cs | 8 ++++---- OpenSim/Data/PGSQL/PGSQLAssetData.cs | 8 ++++---- OpenSim/Data/SQLite/SQLiteAssetData.cs | 8 ++++---- OpenSim/Framework/AssetBase.cs | 3 +++ .../CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 2 ++ 7 files changed, 25 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index ce70396..f94375d 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs @@ -160,18 +160,18 @@ namespace OpenSim.Data.MSSQL @temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)"; string assetName = asset.Name; - if (asset.Name.Length > 64) + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) { - assetName = asset.Name.Substring(0, 64); + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); m_log.WarnFormat( "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; - if (asset.Description.Length > 64) + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - assetDescription = asset.Description.Substring(0, 64); + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); m_log.WarnFormat( "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index c96139d..f03e322 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -171,18 +171,18 @@ namespace OpenSim.Data.MySQL dbcon)) { string assetName = asset.Name; - if (asset.Name.Length > 64) + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) { - assetName = asset.Name.Substring(0, 64); + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); m_log.WarnFormat( "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; - if (asset.Description.Length > 64) + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - assetDescription = asset.Description.Substring(0, 64); + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); m_log.WarnFormat( "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs index 1bf6a9a..430bb9f 100644 --- a/OpenSim/Data/MySQL/MySQLXAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs @@ -210,18 +210,18 @@ namespace OpenSim.Data.MySQL using (MySqlTransaction transaction = dbcon.BeginTransaction()) { string assetName = asset.Name; - if (asset.Name.Length > 64) + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) { - assetName = asset.Name.Substring(0, 64); + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); m_log.WarnFormat( "[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; - if (asset.Description.Length > 64) + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - assetDescription = asset.Description.Substring(0, 64); + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); m_log.WarnFormat( "[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); diff --git a/OpenSim/Data/PGSQL/PGSQLAssetData.cs b/OpenSim/Data/PGSQL/PGSQLAssetData.cs index ca18dc9..5d8b0a2 100644 --- a/OpenSim/Data/PGSQL/PGSQLAssetData.cs +++ b/OpenSim/Data/PGSQL/PGSQLAssetData.cs @@ -166,18 +166,18 @@ namespace OpenSim.Data.PGSQL "; string assetName = asset.Name; - if (asset.Name.Length > 64) + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) { - assetName = asset.Name.Substring(0, 64); + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); m_log.WarnFormat( "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; - if (asset.Description.Length > 64) + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - assetDescription = asset.Description.Substring(0, 64); + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); m_log.WarnFormat( "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 2834bcf..f0dda64 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -134,18 +134,18 @@ namespace OpenSim.Data.SQLite override public void StoreAsset(AssetBase asset) { string assetName = asset.Name; - if (asset.Name.Length > 64) + if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) { - assetName = asset.Name.Substring(0, 64); + assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME); m_log.WarnFormat( "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Name, asset.ID, asset.Name.Length, assetName.Length); } string assetDescription = asset.Description; - if (asset.Description.Length > 64) + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) { - assetDescription = asset.Description.Substring(0, 64); + assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); m_log.WarnFormat( "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index d2c6c57..153a1d0 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -50,6 +50,9 @@ namespace OpenSim.Framework { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public static readonly int MAX_ASSET_NAME = 64; + public static readonly int MAX_ASSET_DESC = 64; + /// /// Data of the Asset /// diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 9d77b19..4bced54 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -514,6 +514,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture scene.RegionInfo.RegionID.ToString()); asset.Data = assetData; asset.Description = String.Format("URL image : {0}", Url); + if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) + asset.Description = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); asset.Local = false; asset.Temporary = ((Disp & DISP_TEMP) != 0); scene.AssetService.Store(asset); -- cgit v1.1