Files
2026-06-04 11:42:34 +02:00

94 lines
2.1 KiB
C#

using System;
using System.Globalization;
using System.IO;
using System.Text;
namespace System.Net
{
// Token: 0x02000236 RID: 566
internal sealed class HttpUtility
{
// Token: 0x060013C7 RID: 5063 RVA: 0x0003D48C File Offset: 0x0003B68C
private HttpUtility()
{
}
// Token: 0x060013C8 RID: 5064 RVA: 0x0003D494 File Offset: 0x0003B694
public static string UrlDecode(string s)
{
return HttpUtility.UrlDecode(s, null);
}
// Token: 0x060013C9 RID: 5065 RVA: 0x0003D4A0 File Offset: 0x0003B6A0
private static char[] GetChars(MemoryStream b, Encoding e)
{
return e.GetChars(b.GetBuffer(), 0, (int)b.Length);
}
// Token: 0x060013CA RID: 5066 RVA: 0x0003D4C4 File Offset: 0x0003B6C4
public static string UrlDecode(string s, Encoding e)
{
if (s == null)
{
return null;
}
if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
{
return s;
}
if (e == null)
{
e = Encoding.GetEncoding(28591);
}
StringBuilder stringBuilder = new StringBuilder();
long num = (long)s.Length;
NumberStyles numberStyles = NumberStyles.HexNumber;
MemoryStream memoryStream = new MemoryStream();
int num2 = 0;
while ((long)num2 < num)
{
if (s[num2] == '%' && (long)(num2 + 2) < num)
{
if (s[num2 + 1] == 'u' && (long)(num2 + 5) < num)
{
if (memoryStream.Length > 0L)
{
stringBuilder.Append(HttpUtility.GetChars(memoryStream, e));
memoryStream.SetLength(0L);
}
stringBuilder.Append((char)int.Parse(s.Substring(num2 + 2, 4), numberStyles));
num2 += 5;
}
else
{
memoryStream.WriteByte((byte)int.Parse(s.Substring(num2 + 1, 2), numberStyles));
num2 += 2;
}
}
else
{
if (memoryStream.Length > 0L)
{
stringBuilder.Append(HttpUtility.GetChars(memoryStream, e));
memoryStream.SetLength(0L);
}
if (s[num2] == '+')
{
stringBuilder.Append(' ');
}
else
{
stringBuilder.Append(s[num2]);
}
}
num2++;
}
if (memoryStream.Length > 0L)
{
stringBuilder.Append(HttpUtility.GetChars(memoryStream, e));
}
return stringBuilder.ToString();
}
}
}