mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
refspec: Detect DEL character in is_valid_name
Prior to this patch the code correctly barfed on control characters with values lower than \040 (space), but failed to account for DEL. This patch fixes the behavior to be consistent with git [1]: > They cannot have ASCII control characters (i.e. bytes whose values are > lower than \040, or \177 DEL) [1]: https://git-scm.com/docs/git-check-ref-format#_description
This commit is contained in:
@@ -819,7 +819,7 @@ int git_reference_list(
|
||||
|
||||
static int is_valid_ref_char(char ch)
|
||||
{
|
||||
if ((unsigned) ch <= ' ')
|
||||
if ((unsigned) ch <= ' ' || ch == '\177') /* ASCII control characters */
|
||||
return 0;
|
||||
|
||||
switch (ch) {
|
||||
|
||||
@@ -21,6 +21,7 @@ void test_refs_isvalidname__can_detect_invalid_formats(void)
|
||||
cl_assert_equal_i(false, is_valid_name("/"));
|
||||
cl_assert_equal_i(false, is_valid_name("//"));
|
||||
cl_assert_equal_i(false, is_valid_name(""));
|
||||
cl_assert_equal_i(false, is_valid_name("refs/heads/\177"));
|
||||
cl_assert_equal_i(false, is_valid_name("refs/heads/sub.lock/webmatrix"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user