Skip to content

UseOSCIndicator breaks pwsh XML OutputFormat #17395

@ajansveld

Description

@ajansveld

Prerequisites

Steps to reproduce

Turning on the OSC progress indicator in a profile causes pwsh to leak ANSI codes in the output. This in turn causes corrupt XML output:

'$PSStyle.Progress.UseOSCIndicator = $true' | Set-Content $PROFILE

This happens on Windows and Linux, including the latest build (7.3.0-preview.3-118-g3f35800a89005339dcb0fec1c3dd741859490aac).

Expected behavior

PS> pwsh -Command {'hello'} | Format-List
hello

Actual behavior

PS> pwsh -Command {'hello'} | Format-List
#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Output">hello</S></Objs>

Error details

This shows the ANSI codes:

PS> pwsh.exe -Command {'hello'} | Format-Hex

   Label: String (System.String) <178F1559>

          Offset Bytes                                           Ascii
                 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
          ------ ----------------------------------------------- -----
0000000000000000 1B 5D 39 3B 34 3B 30 1B 5C 23 3C 20 43 4C 49 58 �]9;4;0�\#< CLIX
0000000000000010 4D 4C                                           ML

   Label: String (System.String) <38B75726>

          Offset Bytes                                           Ascii
                 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
          ------ ----------------------------------------------- -----
0000000000000000 1B 5D 39 3B 34 3B 30 1B 5C 1B 5D 39 3B 34 3B 30 �]9;4;0�\�]9;4;0
0000000000000010 1B 5C 3C 4F 62 6A 73 20 56 65 72 73 69 6F 6E 3D �\<Objs Version=
0000000000000020 22 31 2E 31 2E 30 2E 31 22 20 78 6D 6C 6E 73 3D "1.1.0.1" xmlns=
0000000000000030 22 68 74 74 70 3A 2F 2F 73 63 68 65 6D 61 73 2E "http://schemas.
0000000000000040 6D 69 63 72 6F 73 6F 66 74 2E 63 6F 6D 2F 70 6F microsoft.com/po
0000000000000050 77 65 72 73 68 65 6C 6C 2F 32 30 30 34 2F 30 34 wershell/2004/04
0000000000000060 22 3E 3C 53 20 53 3D 22 4F 75 74 70 75 74 22 3E "><S S="Output">
0000000000000070 68 65 6C 6C 6F 3C 2F 53 3E 3C 2F 4F 62 6A 73 3E hello</S></Objs>

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.4
PSEdition                      Core
GitCommitId                    7.2.4
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions