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