Skip to content

Commit

Permalink
- Also support / in names
Browse files Browse the repository at this point in the history
- Fix error
  • Loading branch information
KoalaBear84 committed Nov 14, 2021
1 parent 2063d68 commit 63de105
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/OpenDirectoryDownloader/Site/GoIndex/BhadooIndexParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static async Task<WebDirectory> ParseIndex(IHtmlDocument htmlDocument, Ht

Console.WriteLine("Check if password is needed (unsupported currently)...");
Logger.Info("Check if password is needed (unsupported currently)...");
OpenDirectoryIndexer.Session.Parameters[Constants.Parameters_Password] = string.Empty;

Dictionary<string, string> postValues = new Dictionary<string, string>
{
Expand Down Expand Up @@ -218,15 +219,15 @@ private static async Task<WebDirectory> ScanAsync(IHtmlDocument htmlDocument, Ht
{
Parser = Parser,
// Yes, string concatenation, do not use new Uri(webDirectory.Uri, file.Name), because things could end with a space...
Url = $"{webDirectory.Uri}{file.Name.Replace("#", "%23")}/",
Url = $"{webDirectory.Uri}{GetSafeName(file.Name)}/",
Name = file.Name
});
}
else
{
webDirectory.Files.Add(new WebFile
{
Url = new Uri(webDirectory.Uri, file.Name).ToString(),
Url = new Uri(webDirectory.Uri, GetSafeName(file.Name)).ToString(),
FileName = file.Name,
FileSize = file.Size
});
Expand Down Expand Up @@ -260,4 +261,11 @@ private static async Task<WebDirectory> ScanAsync(IHtmlDocument htmlDocument, Ht

return webDirectory;
}

private static string GetSafeName(string name)
{
return name
.Replace("#", "%23")
.Replace("/", "%2F");
}
}

0 comments on commit 63de105

Please sign in to comment.