Visitar URL original
Slai Agent Runtime: Preserve decoded text in web response previews by huong8373tt-beep · Pull Request #28167 · PowerShell/PowerShell · GitHub
Skip to content

Slai Agent Runtime: Preserve decoded text in web response previews - #28167

Open
Slai.life (huong8373tt-beep) wants to merge 1 commit into
PowerShell:masterfrom
huong8373tt-beep:slai/fix-webresponse-utf8
Open

Slai.life (huong8373tt-beep) wants to merge 1 commit into
PowerShell:masterfrom
huong8373tt-beep:slai/fix-webresponse-utf8

Conversation

@huong8373tt-beep

Copy link
Copy Markdown

PR Summary

Preserve decoded text in Invoke-WebRequest response previews so non-ASCII response content is not replaced with ASCII fallback characters.

PR Context

Fix #27154.

BasicHtmlWebResponseObject already decodes recognized text responses using the response charset. Override ToString() to return that decoded Content, while retaining the existing ASCII-safe preview behavior for the base WebResponseObject used for non-text or binary responses.

This issue was reproduced on Windows with PowerShell 7.6.6 and validated with a locally built PowerShell 7.7.0-preview.5. The targeted UTF-8 Invoke-WebRequest regression test passes.

This contribution was discovered while Slai Agent Runtime was operating in a Windows environment. The developer authorized this contribution after the issue was reproduced and the fix was validated.

PR Checklist

  • PR has a meaningful title
  • Summarized changes
  • Existing file copyright headers are unchanged
  • This PR is ready to merge
  • Breaking changes
    • None
  • User-facing changes
    • Not Applicable
  • Testing - New and feature
    • Added a regression test for UTF-8 response previews

Copilot AI balanced review requested due to automatic review settings October 8, 2026 11:11
@huong8373tt-beep
Slai.life (huong8373tt-beep) requested a review from a team as a code owner October 8, 2026 11:11
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change reuses existing decoding, preserves binary-response behavior, and includes relevant regression coverage.

0 open findings

What changed in this PR

Fixes #27154 by preserving decoded non-ASCII text in Invoke-WebRequest string representations while retaining existing binary-response behavior.

Changes:

  • Allows text responses to override ToString() and return decoded Content.
  • Adds a UTF-8 regression assertion.
File Description
test/​powershell/​Modules/​Microsoft.PowerShell.Utility/​WebCmdlets.Tests.ps1 Verifies ToString() preserves UTF-8 text.
src/​Microsoft.PowerShell.Commands.Utility/​commands/​utility/​WebCmdlet/​Common/​WebResponseObject.Common.cs Allows overriding ToString() without changing base behavior.
src/​Microsoft.PowerShell.Commands.Utility/​commands/​utility/​WebCmdlet/​Common/​BasicHtmlWebResponseObject.Common.cs Returns decoded text from ToString().

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants