fix: use shlex for pager args, validate netrc host, surface netrc errors#963
Open
jonasagx wants to merge 1 commit intoankitpokhrel:mainfrom
Open
fix: use shlex for pager args, validate netrc host, surface netrc errors#963jonasagx wants to merge 1 commit intoankitpokhrel:mainfrom
jonasagx wants to merge 1 commit intoankitpokhrel:mainfrom
Conversation
- 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
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
pkg/tui: Replacestrings.Splitwithshlex.SplitinPagerOutso 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 toexec.Command.pkg/netrc:Readnow returns an explicit error whenurl.ParseRequestURIsucceeds 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.Readerrors are no longer silently swallowed with_.ErrNetrcEntryNotFoundis 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, andErrNetrcEntryNotFounddistinctiongo test ./pkg/tui/...— 2 new tests covering invalid shlex syntax error path and valid quoted-arg execution viacatgo build ./...— full build passes cleanly