-
Notifications
You must be signed in to change notification settings - Fork 115
Use TrimEnd('\0') instead of Replace("\0", "") for null character stripping #1650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
…ar handling Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
@copilot ты не прав. \0 в двойных кавычках же вообще не удаляет null-String, а только бэкслэш с нулем. В отличие от одинарных кавычек |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses feedback from PR #1649 by refactoring the null character handling in PathHelper.cs to be more targeted and secure. The change improves the implementation from removing all null characters to removing only trailing null characters.
Changes:
- Updated
PathHelper.StripNullCharacters()to useTrimEnd('\0')instead ofReplace("\0", "") - Changed from string literal
"\0"to char literal'\0'for better performance - Enhanced XML documentation to clarify that only trailing null characters are removed and explain the security rationale
В C# string s = "hello\0world";
Console.WriteLine(s.Replace("\0", "").Length); // 10 (было 11)
|
|
@copilot ты опять закоммитил мусор |
Co-authored-by: nixel2007 <1132840+nixel2007@users.noreply.github.com>
|
По-моему, все-таки удаляет. Или я чего-то не знаю. @nixel2007 откуда инфа, что не удаляет? |
|
@EvilBeaver я спутал, копилот и ты правы |

0 New Issues
0 Fixed Issues
0 Accepted Issues
No data about coverage (0.00% Estimated after merge)
TrimEnd('\0')instead ofReplace("\0", "")'\0') instead of string (double quotes"\0")Summary
Fixed the issue raised by @Mr-Rm in PR #1649 comments:
Before:
path.Replace("\0", "")- removed ALL null characters from pathAfter:
path.TrimEnd('\0')- removes only TRAILING null charactersThis is safer because:
TrimEndis more targeted - only fixes the actual issueReplacecould mask security issues like "file.txt\0.exe" where null char hides true extensionOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.