Skip to content

Invoke-WebRequest's .ToString() assumes content is ASCII #27154

@stuartio

Description

@stuartio

Prerequisites

Steps to reproduce

When you call .ToString() on a response from Invoke-WebRequest the code here assumes ascii in the content body

https://github.com/PowerShell/PowerShell/blob/45a80d9a4894802a61637cc7c8843bc66b0bcc5d/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebResponseObject.Common.cs#L187C13-L187C69

If the content is non-ascii this causes characters to be converted to '???'

Expected behavior

Non-ascii characters in the response body remain unchanged

Actual behavior

Non-ascii characters become '???'

Error details

Environment data

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

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issuesWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions