wavefnd / wavefnd/Wave

Convert the Windows environment block to UTF-8 instead of copying narrow API bytes

Open
#526 0 comments 0 reactions 0 assignees View on GitHub
bug cross-platform help wanted
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

`env_read` copies bytes from `GetEnvironmentStringsA` into the environment representation consumed by Wave. The narrow block is not guaranteed to contain UTF-8, and characters unavailable in that encoding may already be lost before copying. Unicode environment keys and values therefore need a wide-API conversion path independent of filesystem path handling.

Source evidence at the head of #520:

- [std/sys/windows/env.wave:9](https://github.com/wavefnd/Wave/blob/2ae0a91c57fd76323124c0e4dff552adbfadbe1b/std/sys/windows/env.wave#L9) — `GetEnvironmentStringsA`
- [std/sys/windows/env.wave:12](https://github.com/wavefnd/Wave/blob/2ae0a91c57fd76323124c0e4dff552adbfadbe1b/std/sys/windows/env.wave#L12) — `pub fun env_read`

Acceptance:

- [ ] Read GetEnvironmentStringsW and convert complete entries to UTF-8 while preserving the double-NUL-terminated block format.
- [ ] Free the matching native block on success and every failure path.
- [ ] Test Korean and supplementary-plane keys/values, an empty value, and destination capacities around the encoded byte length.
- [ ] Preserve the environment block rules for special entries and add no libc dependency.

API/reference context: [GetEnvironmentStrings](https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-getenvironmentstrings).

Related: #385 and #427; #427 requests portable boundary tests, whereas this issue fixes the native encoding implementation.

Audit status: identified by static source inspection; the scenarios above have not been executed during this audit. The permalink fixes the reviewed revision; this report does not claim the defect was introduced by #520.

Contributor guide

Open the contributing guide

Research direction

Start in std/sys/windows/env.wave at env_read and the GetEnvironmentStringsA call, then consult the linked GetEnvironmentStrings reference for the wide API and block rules. Done means Unicode keys and values, including Korean, supplementary-plane text, empty values, and capacity boundaries, are handled in UTF-8; the native block is freed on every path and no libc dependency is added.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.