Skip to content

Fix config's handling of non-ascii characters - #41657

Merged
Feng Wang (chemwolf6922) merged 1 commit into
masterfrom
user/chemwolf6922/fix-mangled-non-ascii-charactor-in-config-parsing
Sep 22, 2026
Merged

Feng Wang (chemwolf6922) merged 1 commit into
masterfrom
user/chemwolf6922/fix-mangled-non-ascii-charactor-in-config-parsing

Conversation

@chemwolf6922

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

When parsing the config file, non-ascii utf-16 values are casted into char. This will mangle non-ascii values in the config file. For example, a custom kernel path containing Chinese characters will cause WSL_E_CUSTOM_KERNEL_NOT_FOUND.

This PR removes the faulty static cast and stores the config value in wstring instead of string. So non-ascii values are preserved.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Modify test:
UnitTests::UnitTets::WriteWslConfig

Manually tested with a custom kernel with a path containing Chinese characters. Before the fix, wsl fails with:

The custom kernel specified in C:\Users\wangfen\.wslconfig was not found: 'D:\-��8\kernel'.
Error code: Wsl/Service/CreateInstance/CreateVm/WSL_E_CUSTOM_KERNEL_NOT_FOUND
If this error was unexpected, please consider searching for existing issues or filing a new issue at https://github.com/microsoft/WSL/issues.

After the fix, wsl boots correctly.

@chemwolf6922
Feng Wang (chemwolf6922) requested a review from a team as a code owner September 21, 2026 08:00
Copilot AI lite review requested due to automatic review settings September 21, 2026 08:00

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.

Copilot review overview

🟢 Approval recommended

The reviewed changes address Unicode handling and include passing test coverage.

Review effort: Lite
Findings: None

What changed in this PR

Fixes .wslconfig parsing so non-ASCII values are preserved correctly.

Changes:

  • Preserve values as wide strings before UTF-8 conversion.
  • Add Unicode round-trip test coverage.
File Summary
test/​windows/​UnitTests.cpp Adds Unicode path round-trip coverage.
src/​shared/​configfile/​configfile.cpp Preserves Unicode config values during parsing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chemwolf6922
Feng Wang (chemwolf6922) merged commit 56244fd into master Sep 22, 2026
12 checks passed
@chemwolf6922
Feng Wang (chemwolf6922) deleted the user/chemwolf6922/fix-mangled-non-ascii-charactor-in-config-parsing branch September 22, 2026 02:42
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.

3 participants