Skip to content

Commit 051f1c9

Browse files
new feedback
1 parent 12620b3 commit 051f1c9

File tree

1 file changed

+2
-5
lines changed
  • src/libraries/System.Web.HttpUtility/src/System/Web/Util

1 file changed

+2
-5
lines changed

src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ internal static void HtmlEncode(string? value, TextWriter output)
129129
private static int IndexOfHtmlAttributeEncodingChars(string s) =>
130130
s.AsSpan().IndexOfAny("<\"'&");
131131

132-
private static bool IsNonAsciiOrSpaceByte(byte b) => (uint)b - 0x20 - 1 >= 0x7F - 0x20 - 1;
133-
134132
internal static string JavaScriptStringEncode(string? value)
135133
{
136134
if (string.IsNullOrEmpty(value))
@@ -576,13 +574,12 @@ private static string UrlPathEncodeImpl(string value)
576574
: value.AsSpan(i);
577575

578576
byte[] bytes = ArrayPool<byte>.Shared.Rent(Encoding.UTF8.GetMaxByteCount(toEncode.Length));
579-
char[] chars = ArrayPool<char>.Shared.Rent(bytes.Length * 3);
580-
581577
int utf8Length = Encoding.UTF8.GetBytes(toEncode, bytes);
578+
char[] chars = ArrayPool<char>.Shared.Rent(utf8Length * 3);
582579
int charCount = 0;
583580
foreach (byte b in bytes.AsSpan(0, utf8Length))
584581
{
585-
if (IsNonAsciiOrSpaceByte(b))
582+
if (!char.IsBetween((char)b, (char)0x21, (char)0x7F))
586583
{
587584
chars[charCount++] = '%';
588585
chars[charCount++] = HexConverter.ToCharLower(b >> 4);

0 commit comments

Comments
 (0)