路径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

@@ -8,6 +8,19 @@ namespace CMLeonOS.Commands.User
{
private static CMLeonOS.UserSystem userSystem;
private static bool ContainsInvalidChars(string input)
{
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\' };
foreach (char c in invalidChars)
{
if (input.Contains(c.ToString()))
{
return true;
}
}
return false;
}
public static void SetUserSystem(CMLeonOS.UserSystem system)
{
userSystem = system;
@@ -80,6 +93,12 @@ namespace CMLeonOS.Commands.User
string password = parts[3];
bool isAdmin = userType == "admin";
if (ContainsInvalidChars(username))
{
showError("Error: Username contains invalid characters: < > : \" | ? / \\");
return;
}
userSystem.AddUser($"{username} {password}", isAdmin);
}
else if (subCommand == "delete")