Skip to content

fix(converter): bound comma splitting for env and exec bind args - #8

Merged
EIonTusk merged 2 commits into
masterfrom
fix/bounded-comma-splitting
Jul 31, 2026
Merged

fix(converter): bound comma splitting for env and exec bind args#8
EIonTusk merged 2 commits into
masterfrom
fix/bounded-comma-splitting

Conversation

@EIonTusk

Copy link
Copy Markdown
Owner

Summary

  • env values containing commas were rejected. Hyprland reads env with CVarList(value, 2) — everything after the first comma is the value — so env = LIST,a,b,c legally sets LIST to "a,b,c". The converter split on every comma and emitted -- TODO: manual review — malformed env instead. Same for envd.
  • exec bind commands were silently rewritten. emitBind split the value on every comma and re-joined the dispatcher args with ", ", turning sh -c "echo a,b,c" into sh -c "echo a, b, c" — a different shell command, with nothing flagged. Hyprland uses CVarList(value, 4) here (5 with a bindd description), so the command keeps its commas and its original spacing.
  • Both now route through a shared splitCommasN(s, n). emitBind keeps the unsplit remainder after the dispatcher and passes it to buildDispatcherRaw, which exec/execr read verbatim; every other dispatcher keeps the split form, so buildDispatcher is now a thin wrapper and no other call site or test changed.
  • README gains a What it handles table under the intro — the per-directive detail previously started below four install sections.

Escaped commas (env = FOO,a\,b) and semicolons keep working. env still flags a value with no comma at all or an empty name, matching Hyprland's own invalid env syntax.

Test plan

  • go vet ./...
  • go test ./...
  • go test -race ./...
  • go test ./internal/converter -fuzz FuzzConvert -fuzztime 15s
  • go build ./cmd/hyprlang2lua
  • Golden coverage added to testdata/04_edge_cases.conf: unescaped commas in exec, bindd + commas, the three env/envd comma forms, and the no-comma flag case. Both .lua and .merged.lua goldens regenerated; the luac -p syntax gate passes.
  • hyprctl dispatch bind rewriting still collapses to direct hl.dsp.* calls.

🤖 Generated with Claude Code

EIonTusk added 2 commits July 31, 2026 14:47
Hyprland parses these directives with a bounded CVarList, not a split on
every comma: `env` uses CVarList(value, 2) and the bind family
CVarList(value, 4) (5 when a `bindd` description is present). Everything
after the last bound separator is one field, commas included.

The converter split unconditionally, which produced two bugs:

  - `env = LIST,a,b,c` was rejected as malformed and emitted a TODO,
    though it legally sets LIST to "a,b,c".
  - an exec bind's command was re-joined with ", ", silently rewriting
    `sh -c "echo a,b,c"` to `sh -c "echo a, b, c"` — a different shell
    command, with no flag raised.

Adds splitCommasN(s, n) and routes both paths through it. emitBind now
also keeps the unsplit remainder after the dispatcher and hands it to
buildDispatcherRaw, which exec/execr use verbatim; every other dispatcher
keeps the split form, so buildDispatcher stays a thin wrapper and no
other call site changes. env still flags a value with no comma at all or
an empty name, matching Hyprland's own "invalid env syntax".
The per-directive detail started at line 100, below the four install
sections, so anything skimming the first screen saw packaging and no
capabilities. Hoists a compact matrix — bind family, submaps, nested
sections, rules, variables, exec/env, dispatchers, comments, and the
--check behaviour — directly under the intro, and surfaces the
zero-install browser converter alongside it. The detailed Phase 1 /
Phase 2 lists stay where they are.
@EIonTusk
EIonTusk merged commit 8d8e34d into master Jul 31, 2026
1 check passed
@EIonTusk
EIonTusk deleted the fix/bounded-comma-splitting branch July 31, 2026 12:50
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.

1 participant