This commit is contained in:
DESKTOP-PB0N82B\admin 2025-11-04 19:37:15 +08:00
parent a0fc3b976d
commit 141bd6df98
3 changed files with 6 additions and 14 deletions

View File

@ -24,17 +24,6 @@ namespace Framework.Test
// }
async void hahaha()
{
while (true)
{
for (int i = 0; i < 10; i++)
{
Debug.Log(i);
}
await UniTask.Delay(1000);
}
}
}
}

View File

@ -25,9 +25,12 @@ namespace Cysharp.Threading.Tasks
void LogError(Exception ex)
{
#if UNITY_2018_3_OR_NEWER
// Unity平台的 LogException 方法直接传递异常对象,是安全的
UnityEngine.Debug.LogException(ex);
#else
Console.WriteLine(ex);
// 使用安全清理方法处理异常消息,防止日志注入攻击
string safeMessage = UniTaskScheduler.SanitizeExceptionMessage(ex.ToString());
Console.WriteLine("TriggerEvent Error: " + safeMessage);
#endif
}

View File

@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks
/// <param name="message">原始异常消息</param>
/// <param name="maxLength">最大长度限制默认1000字符</param>
/// <returns>清理后的安全消息字符串</returns>
static string SanitizeExceptionMessage(string message, int maxLength = 1000)
internal static string SanitizeExceptionMessage(string message, int maxLength = 1000)
{
if (string.IsNullOrEmpty(message))
{