Skip to content

Commit

Permalink
[Aaru.Console] Markup more console output to prevent Spectre from cra…
Browse files Browse the repository at this point in the history
…shing.
  • Loading branch information
claunia committed Oct 26, 2023
1 parent 520eb54 commit da3bbdc
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 7 deletions.
9 changes: 8 additions & 1 deletion Aaru/Commands/Archive/Extract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ public static int Invoke(bool debug, bool verbose, string encoding, bool xattr

string outputPath = Path.Combine(outputDir, fileName);
string destinationDir = Path.GetDirectoryName(outputPath);

if(File.Exists(destinationDir))
{
AaruConsole.ErrorWriteLine(UI.Cannot_write_file_0_output_exists, Markup.Escape(fileName));
continue;
}

if(destinationDir is not null)
Directory.CreateDirectory(destinationDir);

Expand Down Expand Up @@ -450,7 +457,7 @@ public static int Invoke(bool debug, bool verbose, string encoding, bool xattr
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, Markup.Escape(ex.Message)));
AaruConsole.WriteException(ex);

return (int)ErrorNumber.UnexpectedException;
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Archive/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static int Invoke(bool debug, bool verbose, string archivePath, string en
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, Markup.Escape(ex.Message)));
AaruConsole.WriteException(ex);

return (int)ErrorNumber.UnexpectedException;
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Archive/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public static int Invoke(bool debug, bool verbose, string encoding, string archi
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, Markup.Escape(ex.Message)));
AaruConsole.WriteException(ex);

return (int)ErrorNumber.UnexpectedException;
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Filesystem/ExtractFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public static int Invoke(bool debug, bool verbose, string encoding, b
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, Markup.Escape(ex.Message)));
AaruConsole.WriteException(ex);

return (int)ErrorNumber.UnexpectedException;
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Filesystem/Ls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public static int Invoke(bool debug, bool verbose, string encoding, str
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, Markup.Escape(ex.Message)));
AaruConsole.WriteException(ex);

return (int)ErrorNumber.UnexpectedException;
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Image/CreateSidecar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public static int Invoke(bool debug, bool verbose, uint blockSize, [CanBeN
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, Markup.Escape(ex.Message)));
AaruConsole.WriteException(ex);

return (int)ErrorNumber.UnexpectedException;
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Image/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static int Invoke(bool debug, bool verbose, string imagePath)
}
catch(Exception ex)
{
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, Markup.Escape(ex.Message)));
AaruConsole.WriteException(ex);

return (int)ErrorNumber.UnexpectedException;
Expand Down
Empty file modified build.sh
100644 → 100755
Empty file.

0 comments on commit da3bbdc

Please sign in to comment.