mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
路径bug 2+非法字符检测+Lua os.osversion()函数
This commit is contained in:
@@ -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: ");
|
||||
|
||||
Reference in New Issue
Block a user