This commit is contained in:
parent
a0fc3b976d
commit
141bd6df98
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,9 +25,12 @@ namespace Cysharp.Threading.Tasks
|
||||||
void LogError(Exception ex)
|
void LogError(Exception ex)
|
||||||
{
|
{
|
||||||
#if UNITY_2018_3_OR_NEWER
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
// Unity平台的 LogException 方法直接传递异常对象,是安全的
|
||||||
UnityEngine.Debug.LogException(ex);
|
UnityEngine.Debug.LogException(ex);
|
||||||
#else
|
#else
|
||||||
Console.WriteLine(ex);
|
// 使用安全清理方法处理异常消息,防止日志注入攻击
|
||||||
|
string safeMessage = UniTaskScheduler.SanitizeExceptionMessage(ex.ToString());
|
||||||
|
Console.WriteLine("TriggerEvent Error: " + safeMessage);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Cysharp.Threading.Tasks
|
||||||
/// <param name="message">原始异常消息</param>
|
/// <param name="message">原始异常消息</param>
|
||||||
/// <param name="maxLength">最大长度限制,默认1000字符</param>
|
/// <param name="maxLength">最大长度限制,默认1000字符</param>
|
||||||
/// <returns>清理后的安全消息字符串</returns>
|
/// <returns>清理后的安全消息字符串</returns>
|
||||||
static string SanitizeExceptionMessage(string message, int maxLength = 1000)
|
internal static string SanitizeExceptionMessage(string message, int maxLength = 1000)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(message))
|
if (string.IsNullOrEmpty(message))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue