Skip to content

Commit

Permalink
Uri decode lol
Browse files Browse the repository at this point in the history
  • Loading branch information
MistressPlague committed Dec 22, 2023
1 parent e922286 commit 10118ce
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Easy Minecraft Modpacks/MainUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public static string BetterDownloadFile(this WebClient client, string url, strin

var disposition = client.ResponseHeaders["Content-Disposition"];

var filename = disposition != null ? new ContentDisposition(disposition).FileName : url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);
var filename = Workarounds.UrlDecode(disposition != null ? new ContentDisposition(disposition).FileName : url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1));

File.WriteAllBytes($"{targetDir}\\{filename}", data);

Expand Down Expand Up @@ -411,14 +411,19 @@ public static string GetFileName(this WebClient client, string url)

var urlEnding = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1);

var filename = disposition != null ? new ContentDisposition(disposition).FileName : (locationEnding != null ? locationEnding : urlEnding);
var filename = Workarounds.UrlDecode(disposition != null ? new ContentDisposition(disposition).FileName : (locationEnding != null ? locationEnding : urlEnding));

return filename;
}
}

public class Workarounds
{
public static string UrlDecode(string url)
{
return Uri.UnescapeDataString(url);
}

public static string GetRedirectedUrl(string url)
{
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(url);
Expand Down

0 comments on commit 10118ce

Please sign in to comment.