Fix: Un-escape the value before setting LANG#41103
Open
chemwolf6922 wants to merge 1 commit into
Open
Conversation
2 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect LANG values when distro locale files store the value with shell-style escaping/quoting (e.g., LANG="en_US.UTF-8"). It adds shared string helpers to trim and unescape shell-escaped strings, then uses them when parsing locale configuration in the Linux init path, with accompanying unit test updates.
Changes:
- Add
wsl::shared::string::Trim()andwsl::shared::string::UnescapeShell()helpers instringshared.h. - Unescape/trim the locale-file
LANGvalue before callingEnvironment.AddVariable()insrc/linux/init/config.cpp. - Update/extend unit tests to cover quoted locale values and new string helper behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/windows/UnitTests.cpp | Adjusts language config test to validate quoted LANG values using printenv. |
| test/windows/SimpleTests.cpp | Adds coverage for new Trim/UnescapeShell helpers. |
| src/shared/inc/stringshared.h | Introduces Trim and UnescapeShell utilities for shared string handling. |
| src/linux/init/config.cpp | Applies trim + shell-unescape to locale-file LANG prior to setting the environment. |
benhillis
reviewed
Jul 17, 2026
| } | ||
|
|
||
| template <typename TChar> | ||
| inline std::basic_string<TChar> UnescapeShell(const std::basic_string<TChar>& input) |
Member
There was a problem hiding this comment.
On bad input the original string is returned, I guess that's intentional?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
The value in locale files could be shell escaped. The old parsing logic sets the string directly. Which could set
LANGto a wrong value like"en_US.UTF-8".This PR un-escapes the value string before setting it to the env
LANG.PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Update tests:
SimpleTests::SimpleTests::StringHelpers
UnitTests::UnitTests::ConfigUpdateLanguage