If fetching from an anonymous remote via its URL, then the URL gets written into the FETCH_HEAD reference. This is mainly done to give valuable context to some commands, like for example git-merge(1), which will put the URL into the generated MERGE_MSG. As a result, what gets written into FETCH_HEAD may become public in some cases. This is especially important considering that URLs may contain credentials, e.g. when cloning 'https://foo:bar@example.com/repo' we persist the complete URL into FETCH_HEAD and put it without any kind of sanitization into the MERGE_MSG. This is obviously bad, as your login data has now just leaked as soon as you do git-push(1). When writing the URL into FETCH_HEAD, upstream git does strip credentials first. Let's do the same by trying to parse the remote URL as a "real" URL, removing any credentials and then re-formatting the URL. In case this fails, e.g. when it's a file path or not a valid URL, we just fall back to using the URL as-is without any sanitization. Add tests to verify our behaviour.
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| apply | Loading commit data... | |
| attr | Loading commit data... | |
| blame | Loading commit data... | |
| buf | Loading commit data... | |
| checkout | Loading commit data... | |
| cherrypick | Loading commit data... | |
| clar | Loading commit data... | |
| clone | Loading commit data... | |
| commit | Loading commit data... | |
| config | Loading commit data... | |
| core | Loading commit data... | |
| date | Loading commit data... | |
| delta | Loading commit data... | |
| describe | Loading commit data... | |
| diff | Loading commit data... | |
| fetchhead | Loading commit data... | |
| filter | Loading commit data... | |
| graph | Loading commit data... | |
| ignore | Loading commit data... | |
| index | Loading commit data... | |
| iterator | Loading commit data... | |
| mailmap | Loading commit data... | |
| merge | Loading commit data... | |
| message | Loading commit data... | |
| network | Loading commit data... | |
| notes | Loading commit data... | |
| object | Loading commit data... | |
| odb | Loading commit data... | |
| online | Loading commit data... | |
| pack | Loading commit data... | |
| patch | Loading commit data... | |
| path | Loading commit data... | |
| perf | Loading commit data... | |
| rebase | Loading commit data... | |
| refs | Loading commit data... | |
| remote | Loading commit data... | |
| repo | Loading commit data... | |
| reset | Loading commit data... | |
| resources | Loading commit data... | |
| revert | Loading commit data... | |
| revwalk | Loading commit data... | |
| stash | Loading commit data... | |
| status | Loading commit data... | |
| stream | Loading commit data... | |
| stress | Loading commit data... | |
| submodule | Loading commit data... | |
| threads | Loading commit data... | |
| trace | Loading commit data... | |
| transport | Loading commit data... | |
| transports/smart | Loading commit data... | |
| win32 | Loading commit data... | |
| worktree | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| README.md | Loading commit data... | |
| clar.c | Loading commit data... | |
| clar.h | Loading commit data... | |
| clar_libgit2.c | Loading commit data... | |
| clar_libgit2.h | Loading commit data... | |
| clar_libgit2_timer.c | Loading commit data... | |
| clar_libgit2_timer.h | Loading commit data... | |
| clar_libgit2_trace.c | Loading commit data... | |
| clar_libgit2_trace.h | Loading commit data... | |
| generate.py | Loading commit data... | |
| main.c | Loading commit data... | |
| precompiled.c | Loading commit data... | |
| precompiled.h | Loading commit data... | |
| valgrind-supp-mac.txt | Loading commit data... |