路径bug 2+非法字符检测+Lua os.osversion()函数

This commit is contained in:
2026-02-12 00:22:12 +08:00
parent b80c5b45a3
commit 269c61ffdb
5 changed files with 103 additions and 1 deletions

View File

@@ -53,6 +53,19 @@ namespace CMLeonOS
return Convert.ToBase64String(sha256.GetHash());
}
private static bool ContainsInvalidChars(string input)
{
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\' };
foreach (char c in invalidChars)
{
if (input.Contains(c.ToString()))
{
return true;
}
}
return false;
}
public UserSystem()
{
EnsureSysDirectoryExists();
@@ -388,6 +401,17 @@ namespace CMLeonOS
username = global::System.Console.ReadLine();
}
while (ContainsInvalidChars(username))
{
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.Red, global::System.ConsoleColor.Black);
global::System.Console.SetCursorPosition(7, 24);
global::System.Console.Write("Username contains invalid characters: < > : \" | ? / \\ ");
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
global::System.Console.SetCursorPosition(7, 7);
global::System.Console.Write("Username: ");
username = global::System.Console.ReadLine();
}
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
global::System.Console.SetCursorPosition(7, 8);
global::System.Console.Write("Password: ");