Escape markup in file paths for console output
Co-authored-by: StevanFreeborn <65925598+StevanFreeborn@users.noreply.github.com>
This commit is contained in:
co-authored by
StevanFreeborn
parent
cfe0878bcd
commit
f2fdc53222
@@ -68,7 +68,7 @@ internal sealed class DefaultCommand(
|
|||||||
|
|
||||||
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings)
|
public override async Task<int> ExecuteAsync(CommandContext context, Settings settings)
|
||||||
{
|
{
|
||||||
_console.MarkupLine($"[blue]Processing stream:[/] {settings.Stream}");
|
_console.MarkupLine($"[blue]Processing stream:[/] {settings.Stream.EscapeMarkup()}");
|
||||||
var videoStream = _fileSystem.File.OpenRead(settings.Stream);
|
var videoStream = _fileSystem.File.OpenRead(settings.Stream);
|
||||||
|
|
||||||
Stream? audioStream = null;
|
Stream? audioStream = null;
|
||||||
@@ -147,7 +147,7 @@ internal sealed class DefaultCommand(
|
|||||||
});
|
});
|
||||||
|
|
||||||
var directoryUri = new Uri(outputDirectoryPath).AbsoluteUri;
|
var directoryUri = new Uri(outputDirectoryPath).AbsoluteUri;
|
||||||
var panel = new Panel($"[blue link={directoryUri}]{artifactsOutputDirectory}[/]")
|
var panel = new Panel($"[blue link={directoryUri}]{artifactsOutputDirectory.EscapeMarkup()}[/]")
|
||||||
{
|
{
|
||||||
Header = new PanelHeader($"[blue]Shorts created[/] [green]successfully![/]")
|
Header = new PanelHeader($"[blue]Shorts created[/] [green]successfully![/]")
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace StreamShorts.Console.Tests.Unit.Commands;
|
||||||
|
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
|
public class DefaultCommandTests
|
||||||
|
{
|
||||||
|
[Theory]
|
||||||
|
[InlineData("file[with]brackets.mp4", "file[[with]]brackets.mp4")]
|
||||||
|
[InlineData("normal-file.mp4", "normal-file.mp4")]
|
||||||
|
[InlineData("file_with_underscores.mp4", "file_with_underscores.mp4")]
|
||||||
|
[InlineData("file with spaces.mp4", "file with spaces.mp4")]
|
||||||
|
[InlineData("[brackets].mp4", "[[brackets]].mp4")]
|
||||||
|
public void EscapeMarkup_ShouldProperlyEscapeSquareBrackets(string input, string expected)
|
||||||
|
{
|
||||||
|
// Act
|
||||||
|
var result = input.EscapeMarkup();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
result.Should().Be(expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user