Skip to content

Commit

Permalink
fix handling of apostrophes in content-disposition (yuck)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargaj committed Oct 8, 2023
1 parent 0ba19c4 commit 047bd2a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/Dialogs/DownloadDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ private async Task<string> DownloadFile(string url, string targetPath)
}
if (response.Headers["Content-Disposition"] != null)
{
var regex = new System.Text.RegularExpressions.Regex("filename=['\"]?([^'\";]*)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
var regex = new System.Text.RegularExpressions.Regex("filename=([^;]*)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
var match = regex.Match(response.Headers["Content-Disposition"]);
if (match != null && match.Groups.Count == 2)
{
filename = match.Groups[1].Value;
filename = match.Groups[1].Value.Trim('\'', '"');
}
}
if (response.ContentLength > 0)
Expand Down

0 comments on commit 047bd2a

Please sign in to comment.