Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Escape markup in file/folder names
Browse files Browse the repository at this point in the history
  • Loading branch information
sim0n00ps committed Nov 3, 2023
1 parent 5768297 commit 854e24b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions GoFile DL/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ await rootFolder.IterateFoldersAsync(async (folder, folderPath) =>
Directory.CreateDirectory(folderPath);
}

if (folder.Files.Count > 0)
if (folder.Files.Count > 0 && folder.Name != null)
{
AnsiConsole.Markup($"[red]Downloading Content for Folder - {folder.Name}[/]");
AnsiConsole.Markup($"[red]Downloading Content for Folder - {Markup.Escape(folder.Name)}[/]");
}

foreach (Entities.File file in folder.Files)
Expand All @@ -119,7 +119,7 @@ await AnsiConsole.Progress()
.Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new DownloadedColumn(), new RemainingTimeColumn())
.StartAsync(async ctx =>
{
var downloadTask = ctx.AddTask($"[red]{folderPath.Replace("\\", "/")}/{file.Name}[/]");
var downloadTask = ctx.AddTask($"[red]{Markup.Escape(folderPath.Replace("\\", "/"))}/{Markup.Escape(file.Name)}[/]");
downloadTask.MaxValue = file.Size;

bool downloadSuccessful = false;
Expand All @@ -136,7 +136,7 @@ await AnsiConsole.Progress()
}
else
{
AnsiConsole.Markup($"MD5 hash check failed for {file.Name}. Retrying download...");
AnsiConsole.Markup($"MD5 hash check failed for {Markup.Escape(file.Name)}. Retrying download...");
System.IO.File.Delete(folderPath + "/" + file.Name);
}

Expand Down Expand Up @@ -179,7 +179,7 @@ await AnsiConsole.Progress()
.Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new DownloadedColumn(), new RemainingTimeColumn())
.StartAsync(async ctx =>
{
var downloadTask = ctx.AddTask($"[red]{folderPath.Replace("\\", "/")}/{file.Name}[/]");
var downloadTask = ctx.AddTask($"[red]{Markup.Escape(folderPath.Replace("\\", "/"))}/{Markup.Escape(file.Name)}[/]");
downloadTask.MaxValue = file.Size;

bool downloadSuccessful = false;
Expand All @@ -196,7 +196,7 @@ await AnsiConsole.Progress()
}
else
{
AnsiConsole.Markup($"MD5 hash check failed for {file.Name}. Retrying download...");
AnsiConsole.Markup($"MD5 hash check failed for {Markup.Escape(file.Name)}. Retrying download...");
System.IO.File.Delete(folderPath + "/" + file.Name);
}

Expand Down Expand Up @@ -260,9 +260,9 @@ await rootFolder.IterateFoldersAsync(async (folder, folderPath) =>
Directory.CreateDirectory(folderPath);
}

if (folder.Files.Count > 0)
if (folder.Files.Count > 0 && folder.Name != null)
{
AnsiConsole.Markup($"[red]Downloading Content for Folder - {folder.Name}[/]");
AnsiConsole.Markup($"[red]Downloading Content for Folder - {Markup.Escape(folder.Name)}[/]");
}

foreach (Entities.File file in folder.Files)
Expand All @@ -273,7 +273,7 @@ await AnsiConsole.Progress()
.Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new DownloadedColumn(), new RemainingTimeColumn())
.StartAsync(async ctx =>
{
var downloadTask = ctx.AddTask($"[red]{folderPath.Replace("\\", "/")}/{file.Name}[/]");
var downloadTask = ctx.AddTask($"[red]{Markup.Escape(folderPath.Replace("\\", "/"))}/{Markup.Escape(file.Name)}[/]");
downloadTask.MaxValue = file.Size;

bool downloadSuccessful = false;
Expand All @@ -290,7 +290,7 @@ await AnsiConsole.Progress()
}
else
{
AnsiConsole.Markup($"MD5 hash check failed for {file.Name}. Retrying download...");
AnsiConsole.Markup($"MD5 hash check failed for {Markup.Escape(file.Name)}. Retrying download...");
System.IO.File.Delete(folderPath + "/" + file.Name);
}

Expand Down Expand Up @@ -333,7 +333,7 @@ await AnsiConsole.Progress()
.Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new DownloadedColumn(), new RemainingTimeColumn())
.StartAsync(async ctx =>
{
var downloadTask = ctx.AddTask($"[red]{folderPath.Replace("\\", "/")}/{file.Name}[/]");
var downloadTask = ctx.AddTask($"[red]{Markup.Escape(folderPath.Replace("\\", "/"))}/{Markup.Escape(file.Name)}[/]");
downloadTask.MaxValue = file.Size;

bool downloadSuccessful = false;
Expand All @@ -350,7 +350,7 @@ await AnsiConsole.Progress()
}
else
{
AnsiConsole.Markup($"MD5 hash check failed for {file.Name}. Retrying download...");
AnsiConsole.Markup($"MD5 hash check failed for {Markup.Escape(file.Name)}. Retrying download...");
System.IO.File.Delete(folderPath + "/" + file.Name);
}

Expand Down

0 comments on commit 854e24b

Please sign in to comment.