From e2f9aac1c967f7db661c130a8f1b5c9a1bfc9ebd Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 16 Jan 2024 11:05:02 +0800 Subject: [PATCH] remove System.Web --- v2rayN/v2rayN/Common/Utils.cs | 30 ++++++++++++++++++++++++++++-- v2rayN/v2rayUpgrade/MainForm.cs | 3 +-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/v2rayN/v2rayN/Common/Utils.cs b/v2rayN/v2rayN/Common/Utils.cs index daa66c8b..4b4e5b46 100644 --- a/v2rayN/v2rayN/Common/Utils.cs +++ b/v2rayN/v2rayN/Common/Utils.cs @@ -1,5 +1,6 @@ using Microsoft.Win32; using Microsoft.Win32.TaskScheduler; +using System.Collections.Specialized; using System.Diagnostics; using System.Drawing; using System.IO; @@ -13,7 +14,6 @@ using System.Security.Cryptography; using System.Security.Principal; using System.Text; using System.Text.RegularExpressions; -using System.Web; using System.Windows; using System.Windows.Interop; using System.Windows.Media; @@ -302,7 +302,33 @@ namespace v2rayN public static string UrlDecode(string url) { - return HttpUtility.UrlDecode(url); + return Uri.UnescapeDataString(url); + //return HttpUtility.UrlDecode(url); + } + + public static NameValueCollection ParseQueryString(string query) + { + var result = new NameValueCollection(StringComparer.OrdinalIgnoreCase); + if (IsNullOrEmpty(query)) + { + return result; + } + + var parts = query[1..].Split(new[] { '&' }, StringSplitOptions.RemoveEmptyEntries); + foreach (var part in parts) + { + var keyValue = part.Split(['=']); + if (keyValue.Length != 2) + { + continue; + } + var key = Uri.UnescapeDataString(keyValue[0]); + var val = Uri.UnescapeDataString(keyValue[1]); + + result.Add(key, val); + } + + return result; } public static string GetMD5(string str) diff --git a/v2rayN/v2rayUpgrade/MainForm.cs b/v2rayN/v2rayUpgrade/MainForm.cs index 02f0e933..39f8196c 100644 --- a/v2rayN/v2rayUpgrade/MainForm.cs +++ b/v2rayN/v2rayUpgrade/MainForm.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Text; -using System.Web; using System.Windows.Forms; namespace v2rayUpgrade @@ -18,7 +17,7 @@ namespace v2rayUpgrade InitializeComponent(); if (args.Length > 0) { - fileName = HttpUtility.UrlDecode(string.Join(" ", args)); + fileName = Uri.UnescapeDataString(string.Join(" ", args)); } else {