Skip to content

Commit

Permalink
[Aaru] Escape debug output of command parameters that can make `Spect…
Browse files Browse the repository at this point in the history
…re.Console` throw an exception if user input contains a square bracket.
  • Loading branch information
claunia committed Oct 8, 2023
1 parent 42b2a81 commit 4994a85
Show file tree
Hide file tree
Showing 21 changed files with 82 additions and 82 deletions.
6 changes: 3 additions & 3 deletions Aaru/Commands/Archive/Extract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public static int Invoke(bool debug, bool verbose, string encoding, bool xattr
Statistics.AddCommand("archive-extract");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", archivePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputDir);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", Markup.Escape(encoding ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(archivePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", Markup.Escape(outputDir ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--xattrs={0}", xattrs);

Expand Down
8 changes: 4 additions & 4 deletions Aaru/Commands/Archive/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public static int Invoke(bool debug, bool verbose, string archivePath, string en

Statistics.AddCommand("archive-info");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", archivePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "input={0}", Markup.Escape(archivePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "encoding={0}", Markup.Escape(encoding ?? ""));

IFilter inputFilter = null;

Expand Down
4 changes: 2 additions & 2 deletions Aaru/Commands/Archive/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public static int Invoke(bool debug, bool verbose, string encoding, string archi
}

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", Markup.Escape(encoding ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--long-format={0}", longFormat);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", archivePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(archivePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("archive-list");

Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Device/DeviceReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static int Invoke(bool debug, bool verbose, string devicePath, bool trapD
Statistics.AddCommand("device-report");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", Markup.Escape(devicePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);

if(devicePath.Length == 2 && devicePath[1] == ':' && devicePath[0] != '/' && char.IsLetter(devicePath[0]))
Expand Down
4 changes: 2 additions & 2 deletions Aaru/Commands/Device/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public static int Invoke(bool debug, bool verbose, string devicePath, string out
Statistics.AddCommand("device-info");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", devicePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output-prefix={0}", outputPrefix);
AaruConsole.DebugWriteLine(MODULE_NAME, "--device={0}", Markup.Escape(devicePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--output-prefix={0}", Markup.Escape(outputPrefix ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);

if(devicePath.Length == 2 && devicePath[1] == ':' && devicePath[0] != '/' && char.IsLetter(devicePath[0]))
Expand Down
8 changes: 4 additions & 4 deletions Aaru/Commands/Filesystem/ExtractFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public static int Invoke(bool debug, bool verbose, string encoding, b
Statistics.AddCommand("extract-files");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputDir);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", Markup.Escape(encoding ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", Markup.Escape(options ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", Markup.Escape(outputDir ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--xattrs={0}", xattrs);

Expand Down
4 changes: 2 additions & 2 deletions Aaru/Commands/Filesystem/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public static int Invoke(bool verbose, bool debug, string encoding, bool files
Statistics.AddCommand("fs-info");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", Markup.Escape(encoding ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--filesystems={0}", filesystems);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--partitions={0}", partitions);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);

Expand Down
6 changes: 3 additions & 3 deletions Aaru/Commands/Filesystem/Ls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public static int Invoke(bool debug, bool verbose, string encoding, str
}

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", Markup.Escape(encoding ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", Markup.Escape(options ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Statistics.AddCommand("ls");

Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Image/Checksum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static int Invoke(bool debug, bool verbose, bool adler32, boo
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher16={0}", fletcher16);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fletcher32={0}", fletcher32);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--md5={0}", md5);
AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks);
AaruConsole.DebugWriteLine(MODULE_NAME, "--sha1={0}", sha1);
Expand Down
4 changes: 2 additions & 2 deletions Aaru/Commands/Image/Compare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public static int Invoke(bool debug, bool verbose, string imagePath1, string ima
Statistics.AddCommand("compare");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input1={0}", imagePath1);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input2={0}", imagePath2);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input1={0}", Markup.Escape(imagePath1 ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--input2={0}", Markup.Escape(imagePath2 ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);

IFilter inputFilter1 = null;
Expand Down
60 changes: 30 additions & 30 deletions Aaru/Commands/Image/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,37 +223,37 @@ public static int Invoke(bool verbose, bool debug, string cicmXml, string comm

Statistics.AddCommand("convert-image");

AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", cicmXml);
AaruConsole.DebugWriteLine(MODULE_NAME, "--comments={0}", comments);
AaruConsole.DebugWriteLine(MODULE_NAME, "--count={0}", count);
AaruConsole.DebugWriteLine(MODULE_NAME, "--creator={0}", creator);
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-manufacturer={0}", driveManufacturer);
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-model={0}", driveModel);
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-revision={0}", driveFirmwareRevision);
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-serial={0}", driveSerialNumber);
AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force);
AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", format);
AaruConsole.DebugWriteLine(MODULE_NAME, "--geometry={0}", geometry);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", inputPath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-barcode={0}", mediaBarcode);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-lastsequence={0}", lastMediaSequence);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-manufacturer={0}", mediaManufacturer);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-model={0}", mediaModel);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-partnumber={0}", mediaPartNumber);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-sequence={0}", mediaSequence);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-serial={0}", mediaSerialNumber);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-title={0}", mediaTitle);
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", options);
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", outputPath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--resume-file={0}", resumeFile);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--cicm-xml={0}", Markup.Escape(cicmXml ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--comments={0}", Markup.Escape(comments ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--count={0}", count);
AaruConsole.DebugWriteLine(MODULE_NAME, "--creator={0}", Markup.Escape(creator ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-manufacturer={0}", Markup.Escape(driveManufacturer ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-model={0}", Markup.Escape(driveModel ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-revision={0}", Markup.Escape(driveFirmwareRevision ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--drive-serial={0}", Markup.Escape(driveSerialNumber ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--force={0}", force);
AaruConsole.DebugWriteLine(MODULE_NAME, "--format={0}", Markup.Escape(format ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--geometry={0}", Markup.Escape(geometry ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(inputPath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-barcode={0}", Markup.Escape(mediaBarcode ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-lastsequence={0}", lastMediaSequence);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-manufacturer={0}", Markup.Escape(mediaManufacturer ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-model={0}", Markup.Escape(mediaModel ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-partnumber={0}", Markup.Escape(mediaPartNumber ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-sequence={0}", mediaSequence);
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-serial={0}", Markup.Escape(mediaSerialNumber ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--media-title={0}", Markup.Escape(mediaTitle ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--options={0}", Markup.Escape(options ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--output={0}", Markup.Escape(outputPath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--resume-file={0}", Markup.Escape(resumeFile ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-position={0}", fixSubchannelPosition);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc);
AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels);
AaruConsole.DebugWriteLine(MODULE_NAME, "--decrypt={0}", decrypt);
AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", aaruMetadata);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel={0}", fixSubchannel);
AaruConsole.DebugWriteLine(MODULE_NAME, "--fix-subchannel-crc={0}", fixSubchannelCrc);
AaruConsole.DebugWriteLine(MODULE_NAME, "--generate-subchannels={0}", generateSubchannels);
AaruConsole.DebugWriteLine(MODULE_NAME, "--decrypt={0}", decrypt);
AaruConsole.DebugWriteLine(MODULE_NAME, "--aaru-metadata={0}", Markup.Escape(aaruMetadata ?? ""));

Dictionary<string, string> parsedOptions = Core.Options.Parse(options);
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Parsed_options);
Expand Down
4 changes: 2 additions & 2 deletions Aaru/Commands/Image/CreateSidecar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public static int Invoke(bool debug, bool verbose, uint blockSize, [CanBeN

AaruConsole.DebugWriteLine(MODULE_NAME, "--block-size={0}", blockSize);
AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", encodingName);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--encoding={0}", Markup.Escape(encodingName ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--tape={0}", tape);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);

Expand Down
4 changes: 2 additions & 2 deletions Aaru/Commands/Image/Decode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public static int Invoke(bool verbose, bool debug, bool diskTags, string imageP

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--disk-tags={0}", diskTags);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", Markup.Escape(length ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--sector-tags={0}", sectorTags);
AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", startSector);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Image/Entropy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static int Invoke(bool debug, bool verbose, bool duplicatedSectors, strin

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--duplicated-sectors={0}", duplicatedSectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--separated-tracks={0}", separatedTracks);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--whole-disc={0}", wholeDisc);
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 @@ -95,7 +95,7 @@ public static int Invoke(bool debug, bool verbose, string imagePath)
Statistics.AddCommand("image-info");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);

IFilter inputFilter = null;
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Image/Print.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static int Invoke(bool debug, bool verbose, string imagePath, ulong len
Statistics.AddCommand("print-hex");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--length={0}", length);
AaruConsole.DebugWriteLine(MODULE_NAME, "--long-sectors={0}", longSectors);
AaruConsole.DebugWriteLine(MODULE_NAME, "--start={0}", start);
Expand Down
2 changes: 1 addition & 1 deletion Aaru/Commands/Image/Verify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static int Invoke(bool debug, bool verbose, string imagePath, bool
Statistics.AddCommand("verify");

AaruConsole.DebugWriteLine(MODULE_NAME, "--debug={0}", debug);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", imagePath);
AaruConsole.DebugWriteLine(MODULE_NAME, "--input={0}", Markup.Escape(imagePath ?? ""));
AaruConsole.DebugWriteLine(MODULE_NAME, "--verbose={0}", verbose);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-disc={0}", verifyDisc);
AaruConsole.DebugWriteLine(MODULE_NAME, "--verify-sectors={0}", verifySectors);
Expand Down
Loading

0 comments on commit 4994a85

Please sign in to comment.