|
|
@@ -13,54 +13,57 @@ namespace Filters
|
|
|
string cipherText = "";
|
|
|
try
|
|
|
{
|
|
|
- if(request.Method.ToLower() == "get")
|
|
|
+ if(!request.Path.Value.Contains("upload"))
|
|
|
{
|
|
|
- cipherText = request.Query["value"];
|
|
|
- cipherText = HttpUtility.UrlDecode(cipherText);
|
|
|
- cipherText = Decrypt(cipherText);
|
|
|
- cipherText = HttpUtility.UrlDecode(cipherText);
|
|
|
- }
|
|
|
- else if(request.Method.ToLower() == "delete")
|
|
|
- {
|
|
|
- string path = request.Path.Value;
|
|
|
- string value = path.Substring(path.LastIndexOf("/") + 1);
|
|
|
- path = path.Substring(0, path.LastIndexOf("/") + 1);
|
|
|
- value = Decrypt(value);
|
|
|
- path += value;
|
|
|
- request.Path = new PathString(path);
|
|
|
- request.RouteValues["id"] = value;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- using var reader = new StreamReader(request.Body, leaveOpen: true);
|
|
|
- cipherText = reader.ReadToEnd();
|
|
|
- if(cipherText.StartsWith("value="))
|
|
|
+ if(request.Method.ToLower() == "get")
|
|
|
{
|
|
|
- cipherText = cipherText.Replace("value=", "");
|
|
|
+ cipherText = request.Query["value"];
|
|
|
+ cipherText = HttpUtility.UrlDecode(cipherText);
|
|
|
+ cipherText = Decrypt(cipherText);
|
|
|
+ cipherText = HttpUtility.UrlDecode(cipherText);
|
|
|
+ }
|
|
|
+ else if(request.Method.ToLower() == "delete")
|
|
|
+ {
|
|
|
+ string path = request.Path.Value;
|
|
|
+ string value = path.Substring(path.LastIndexOf("/") + 1);
|
|
|
+ path = path.Substring(0, path.LastIndexOf("/") + 1);
|
|
|
+ value = Decrypt(value);
|
|
|
+ path += value;
|
|
|
+ request.Path = new PathString(path);
|
|
|
+ request.RouteValues["id"] = value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ using var reader = new StreamReader(request.Body, leaveOpen: true);
|
|
|
+ cipherText = reader.ReadToEnd();
|
|
|
+ if(cipherText.StartsWith("value="))
|
|
|
+ {
|
|
|
+ cipherText = cipherText.Replace("value=", "");
|
|
|
+ }
|
|
|
+ cipherText = Decrypt(cipherText);
|
|
|
+ }
|
|
|
+ if (string.IsNullOrWhiteSpace(cipherText))
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
}
|
|
|
- cipherText = Decrypt(cipherText);
|
|
|
- }
|
|
|
- if (string.IsNullOrWhiteSpace(cipherText))
|
|
|
- {
|
|
|
- return 1;
|
|
|
- }
|
|
|
|
|
|
- if(request.Method.ToLower() == "get")
|
|
|
- {
|
|
|
- cipherText = GetParams(cipherText);
|
|
|
- var queryDict = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(cipherText);
|
|
|
- var newQuery = new QueryCollection(queryDict);
|
|
|
- request.Query = newQuery;
|
|
|
- request.QueryString = new QueryString("?" + cipherText);
|
|
|
- }
|
|
|
- else if(request.Method.ToLower() == "delete") {}
|
|
|
- else
|
|
|
- {
|
|
|
- var bytes = Encoding.UTF8.GetBytes(cipherText);
|
|
|
- var ms = new MemoryStream(bytes);
|
|
|
- request.Body = ms; // 替换为明文
|
|
|
- request.ContentLength = bytes.Length;
|
|
|
- ms.Position = 0;
|
|
|
+ if(request.Method.ToLower() == "get")
|
|
|
+ {
|
|
|
+ cipherText = GetParams(cipherText);
|
|
|
+ var queryDict = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(cipherText);
|
|
|
+ var newQuery = new QueryCollection(queryDict);
|
|
|
+ request.Query = newQuery;
|
|
|
+ request.QueryString = new QueryString("?" + cipherText);
|
|
|
+ }
|
|
|
+ else if(request.Method.ToLower() == "delete") {}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var bytes = Encoding.UTF8.GetBytes(cipherText);
|
|
|
+ var ms = new MemoryStream(bytes);
|
|
|
+ request.Body = ms; // 替换为明文
|
|
|
+ request.ContentLength = bytes.Length;
|
|
|
+ ms.Position = 0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|