Skip to content

fix: use shlex for pager args, validate netrc host, surface netrc errors#963

Open
jonasagx wants to merge 1 commit intoankitpokhrel:mainfrom
jonasagx:fix/shlex-pager-netrc-empty-host
Open

fix: use shlex for pager args, validate netrc host, surface netrc errors#963
jonasagx wants to merge 1 commit intoankitpokhrel:mainfrom
jonasagx:fix/shlex-pager-netrc-empty-host

Conversation

@jonasagx
Copy link
Copy Markdown

@jonasagx jonasagx commented Mar 7, 2026

Summary

  • pkg/tui: Replace strings.Split with shlex.Split in PagerOut so pager commands with quoted arguments (e.g. less --prompt="foo bar") are parsed correctly. Also returns an error on invalid shlex syntax (e.g. unclosed quotes) instead of silently passing a malformed command to exec.Command.
  • pkg/netrc: Read now returns an explicit error when url.ParseRequestURI succeeds but produces an empty host (e.g. an absolute path like /some/path). Previously this would silently match against any netrc entry whose machine field was also empty.
  • api/client: netrc.Read errors are no longer silently swallowed with _. ErrNetrcEntryNotFound is still treated as a normal not-found case, but other errors (malformed server URL, file read failure) are now printed as a warning to stderr, making auth failures easier to diagnose.

Test plan

  • go test ./pkg/netrc/... — 3 new tests covering empty-host error, URL parse error, and ErrNetrcEntryNotFound distinction
  • go test ./pkg/tui/... — 2 new tests covering invalid shlex syntax error path and valid quoted-arg execution via cat
  • go build ./... — full build passes cleanly

- pkg/tui: replace strings.Split with shlex.Split in PagerOut so pager
  commands with quoted arguments (e.g. less --prompt="foo bar") are
  parsed correctly; return an error on invalid shlex syntax
- pkg/netrc: return an explicit error when ParseRequestURI succeeds but
  produces an empty host (e.g. an absolute path like /some/path),
  preventing a silent empty-string match against netrc entries
- api/client: stop swallowing all netrc.Read errors; ErrNetrcEntryNotFound
  is still treated as a normal not-found case, but other errors (malformed
  URL, file read failure) are now printed as a warning to stderr
- Add unit tests covering all three changes
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