Skip to content

Commit dfb2523

Browse files
committed
Remove ANSI escape characters from strings in object properties
1 parent e8bf6cf commit dfb2523

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Microsoft.PowerShell.ConsoleGuiTools/OutConsoleGridviewCmdletCommand.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ baseObject is PSReference ||
111111
ThrowTerminatingError(error);
112112
}
113113

114+
// Remove any potential ANSI escape codes from strings
115+
foeach (var property in input.Properties)
116+
{
117+
if (property.Value is string)
118+
{
119+
var stringDecorated = new StringDecorated(property.Value as string);
120+
property.Value = stringDecorated.ToString(OutputRendering.PlainText);
121+
}
122+
}
123+
114124
_psObjects.Add(input);
115125
}
116126

0 commit comments

Comments
 (0)