mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
用户名空白检测+修复一重大bug
This commit is contained in:
@@ -1 +1 @@
|
||||
2026-02-19 17:35:30
|
||||
2026-02-24 20:06:20
|
||||
@@ -1 +1 @@
|
||||
0147679
|
||||
0386511
|
||||
@@ -308,7 +308,11 @@ namespace CMLeonOS
|
||||
{
|
||||
if (File.Exists(fullPath))
|
||||
{
|
||||
return File.ReadAllText(fullPath);
|
||||
using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
|
||||
using (StreamReader sr = new StreamReader(fs))
|
||||
{
|
||||
return sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -389,15 +393,15 @@ namespace CMLeonOS
|
||||
return currentDirectory;
|
||||
}
|
||||
|
||||
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' };
|
||||
foreach (char c in invalidChars)
|
||||
{
|
||||
if (path.Contains(c.ToString()))
|
||||
{
|
||||
Console.WriteLine($"Error: Invalid character in path: '{c}'");
|
||||
return currentDirectory;
|
||||
}
|
||||
}
|
||||
//char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*' };
|
||||
//foreach (char c in invalidChars)
|
||||
//{
|
||||
// if (path.Contains(c.ToString()))
|
||||
// {
|
||||
// Console.WriteLine($"Error: Invalid character in path: '{c}'");
|
||||
// return currentDirectory;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (path.Contains("//") || path.Contains("\\\\"))
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace CMLeonOS
|
||||
|
||||
private static bool ContainsInvalidChars(string input)
|
||||
{
|
||||
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\' };
|
||||
char[] invalidChars = { '<', '>', ':', '"', '|', '?', '*', '/', '\\', ' ' };
|
||||
foreach (char c in invalidChars)
|
||||
{
|
||||
if (input.Contains(c.ToString()))
|
||||
@@ -405,7 +405,7 @@ namespace CMLeonOS
|
||||
{
|
||||
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: < > : \" | ? / \\ ");
|
||||
global::System.Console.Write("Username contains invalid characters: < > : \" | ? * / \\ space");
|
||||
CMLeonOS.UI.TUIHelper.SetColors(global::System.ConsoleColor.White, global::System.ConsoleColor.Black);
|
||||
global::System.Console.SetCursorPosition(7, 7);
|
||||
global::System.Console.Write("Username: ");
|
||||
|
||||
@@ -47,11 +47,13 @@ namespace CMLeonOS
|
||||
|
||||
if (value != null && fileSystem != null)
|
||||
{
|
||||
string fullPath = fileSystem.GetFullPath(value);
|
||||
|
||||
if (System.IO.File.Exists(fullPath))
|
||||
try
|
||||
{
|
||||
string fullPath = fileSystem.GetFullPath(value);
|
||||
string text = fileSystem.ReadFile(fullPath);
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
text = text.Replace("\r\n", "\n");
|
||||
lines.AddRange(text.Split('\n'));
|
||||
}
|
||||
@@ -60,6 +62,11 @@ namespace CMLeonOS
|
||||
lines.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
lines.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.Add(string.Empty);
|
||||
|
||||
Reference in New Issue
Block a user