Revision c716fe4bd917e013bf376a678b3a924447777b2d authored by Jeff King on 12 March 2020, 05:31:11 UTC, committed by Jeff King on 12 March 2020, 06:55:24 UTC
The credential protocol can't represent newlines in values, but URLs can
embed percent-encoded newlines in various components. A previous commit
taught the low-level writing routines to die() when encountering this,
but we can be a little friendlier to the user by detecting them earlier
and handling them gracefully.

This patch teaches credential_from_url() to notice such components,
issue a warning, and blank the credential (which will generally result
in prompting the user for a username and password). We blank the whole
credential in this case. Another option would be to blank only the
invalid component. However, we're probably better off not feeding a
partially-parsed URL result to a credential helper. We don't know how a
given helper would handle it, so we're better off to err on the side of
matching nothing rather than something unexpected.

The die() call in credential_write() is _probably_ impossible to reach
after this patch. Values should end up in credential structs only by URL
parsing (which is covered here), or by reading credential protocol input
(which by definition cannot read a newline into a value). But we should
definitely keep the low-level check, as it's our final and most accurate
line of defense against protocol injection attacks. Arguably it could
become a BUG(), but it probably doesn't matter much either way.

Note that the public interface of credential_from_url() grows a little
more than we need here. We'll use the extra flexibility in a future
patch to help fsck catch these cases.
1 parent 17f1c0b
History
File Mode Size
.gitignore -rw-r--r-- 7 bytes
README -rw-r--r-- 10.6 KB
TEAMS -rw-r--r-- 2.4 KB
bg.po -rw-r--r-- 644.6 KB
ca.po -rw-r--r-- 496.2 KB
de.po -rw-r--r-- 514.3 KB
es.po -rw-r--r-- 490.1 KB
fr.po -rw-r--r-- 535.0 KB
git.pot -rw-r--r-- 320.1 KB
is.po -rw-r--r-- 3.3 KB
it.po -rw-r--r-- 128.2 KB
ko.po -rw-r--r-- 523.6 KB
pt_PT.po -rw-r--r-- 482.9 KB
ru.po -rw-r--r-- 605.0 KB
sv.po -rw-r--r-- 518.1 KB
vi.po -rw-r--r-- 572.3 KB
zh_CN.po -rw-r--r-- 472.2 KB

README

back to top