mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Ensure proper filename of generated torrent (#1085)
Ensure that the filename of a torrent file sent to browser client doesn't contain invalid character and thus preventing HTTP Error 500.
This commit is contained in:
@@ -56,6 +56,12 @@ namespace Jackett.Controllers
|
||||
var torrentDictionary = BEncodedDictionary.DecodeTorrent(downloadBytes);
|
||||
downloadBytes = torrentDictionary.Encode();
|
||||
|
||||
char[] invalidChars = System.IO.Path.GetInvalidFileNameChars();
|
||||
for(int i=0;i<file.Count();i++)
|
||||
if(invalidChars.Contains(file[i])) {
|
||||
file = file.Remove(i, 1).Insert(i, " ");
|
||||
}
|
||||
|
||||
var result = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
result.Content = new ByteArrayContent(downloadBytes);
|
||||
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-bittorrent");
|
||||
|
Reference in New Issue
Block a user