Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 621c46f

Browse files
Merge pull request #262 from github-for-unity/fixes/255-harden-config-parser
Harden the git config parser to handle remote entries without a url better
2 parents c9b9bbb + 2c5ea62 commit 621c46f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/GitHub.Api/Git/GitConfig.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ public IEnumerable<ConfigRemote> GetRemotes()
8686
return groups
8787
.Where(x => x.Key == "remote")
8888
.SelectMany(x => x.Value)
89+
.Where(x => x.Value.TryGetString("url") != null)
8990
.Select(x => new ConfigRemote
9091
{
9192
Name = x.Key,
92-
Url = x.Value.GetString("url")
93+
Url = x.Value.TryGetString("url")
9394
});
9495
}
9596

@@ -98,7 +99,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
9899
return groups
99100
.Where(x => x.Key == "remote")
100101
.SelectMany(x => x.Value)
101-
.Where(x => x.Key == remote)
102+
.Where(x => x.Key == remote && x.Value.TryGetString("url") != null)
102103
.Select(x => new ConfigRemote
103104
{
104105
Name = x.Key,

0 commit comments

Comments
 (0)