Colorscape Love (#3326)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
parent
b44f89d1e8
commit
a847468a6c
42 changed files with 1009 additions and 429 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System.Globalization;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace API.Extensions;
|
||||
|
|
@ -10,6 +11,23 @@ public static class StringExtensions
|
|||
RegexOptions.ExplicitCapture | RegexOptions.Compiled,
|
||||
Services.Tasks.Scanner.Parser.Parser.RegexTimeout);
|
||||
|
||||
public static string Sanitize(this string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
return string.Empty;
|
||||
|
||||
// Remove all newline and control characters
|
||||
var sanitized = input
|
||||
.Replace(Environment.NewLine, "")
|
||||
.Replace("\n", "")
|
||||
.Replace("\r", "");
|
||||
|
||||
// Optionally remove other potentially unwanted characters
|
||||
sanitized = Regex.Replace(sanitized, @"[^\u0020-\u007E]", string.Empty); // Removes non-printable ASCII
|
||||
|
||||
return sanitized.Trim(); // Trim any leading/trailing whitespace
|
||||
}
|
||||
|
||||
public static string SentenceCase(this string value)
|
||||
{
|
||||
return SentenceCaseRegex.Replace(value.ToLower(), s => s.Value.ToUpper());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue