netrc scans refactor#21624
Closed
icing wants to merge 5 commits into
Closed
Conversation
bagder
reviewed
May 15, 2026
4f0c863 to
0a7bb4a
Compare
There was a problem hiding this comment.
Pull request overview
Refactors the internal .netrc parsing/scanning logic to a lexer/scanner approach, updates credential override logic to use the new scanner, and extends unit coverage to ensure .netrc scanning does not incorrectly “succeed” with a password when the requested login does not match.
Changes:
- Replace
Curl_parsenetrc()withCurl_netrc_scan()(hostname + optional user) and rework parsing into a token-based scanner. - Update
override_login()to useCurl_netrc_scan()and simplify the netrc decision flow. - Update unit1304 and add a regression case for “host matched but login mismatched must not yield a password”.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
lib/netrc.c |
Replaces the legacy .netrc parser with a lexer/scanner implementation and introduces Curl_netrc_scan() plumbing. |
lib/netrc.h |
Updates the public internal API surface: declares Curl_netrc_scan() and removes the old parser prototype. |
lib/url.c |
Switches netrc handling in override_login() to the new scanner and consolidates the credential-selection logic. |
tests/unit/unit1304.c |
Updates tests to the new scanner API and adds a regression test for login mismatch not leaking passwords. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+391
to
+397
| if(sc->user) { | ||
| if(Curl_timestrcmp(sc->user, sc->login)) | ||
| goto out; | ||
| /* We look for a specific user, | ||
| * entry is only interesting with password */ | ||
| sc->found = !!sc->passwd; | ||
| } |
Refactor the netrc scanner. Add test case for checking that the last matched machine with unmatched login does not return the password as success (unit1304).
0a7bb4a to
751cd93
Compare
outcast36
pushed a commit
to greearb/curl
that referenced
this pull request
Jun 3, 2026
Refactor the netrc scanner. Add test case for checking that the last matched machine with unmatched login does not return the password as success (unit1304). Closes curl#21624
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.
Refactor the netrc scanner. Add test case for checking that the last matched machine with unmatched login does not return the password as success (unit1304).