diff --git a/src/Runner.Worker/Handlers/OutputManager.cs b/src/Runner.Worker/Handlers/OutputManager.cs index 8b97c867d95..4c9d5f4f405 100644 --- a/src/Runner.Worker/Handlers/OutputManager.cs +++ b/src/Runner.Worker/Handlers/OutputManager.cs @@ -13,10 +13,10 @@ namespace GitHub.Runner.Worker.Handlers { public sealed class OutputManager : IDisposable { - private const string _colorCodePrefix = "\033["; + private const string _colorCodePrefix = "\x1b["; private const int _maxAttempts = 3; private const string _timeoutKey = "GITHUB_ACTIONS_RUNNER_ISSUE_MATCHER_TIMEOUT"; - private static readonly Regex _colorCodeRegex = new(@"\x0033\[[0-9;]*m?", RegexOptions.Compiled | RegexOptions.CultureInvariant); + private static readonly Regex _colorCodeRegex = new(@"\x1b\[[0-9;]*m?", RegexOptions.Compiled | RegexOptions.CultureInvariant); private readonly IActionCommandManager _commandManager; private readonly ContainerInfo _container; private readonly IExecutionContext _executionContext; diff --git a/src/Test/L0/Worker/OutputManagerL0.cs b/src/Test/L0/Worker/OutputManagerL0.cs index 8bac9393362..920ccdd175c 100644 --- a/src/Test/L0/Worker/OutputManagerL0.cs +++ b/src/Test/L0/Worker/OutputManagerL0.cs @@ -403,7 +403,8 @@ public void MatcherRemoveColorCodes() }, }, }); - Process("the error: \033[31mred, \033[1;31mbright red, \033[mreset"); + // Shells may support "\033", but in C# that translates to a null followed by "33" + Process("the error: \x1B[31mred, \x1B[1;31mbright red, \x1B[mreset"); Assert.Equal(1, _issues.Count); Assert.Equal("red, bright red, reset", _issues[0].Item1.Message); Assert.Equal("the error: red, bright red, reset", _issues[0].Item2);