Skip to content

Commit

Permalink
Forbid DEL characters in reference names
Browse files Browse the repository at this point in the history
DEL is an ASCII control character and therefore should not be
permitted in reference names.  Add tests for this and other unusual
characters.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed Aug 27, 2011
1 parent 2f633f4 commit f3738c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)

static inline int bad_ref_char(int ch)
{
if (((unsigned) ch) <= ' ' ||
if (((unsigned) ch) <= ' ' || ch == 0x7f ||
ch == '~' || ch == '^' || ch == ':' || ch == '\\')
return 1;
/* 2.13 Pattern Matching Notation */
Expand Down
3 changes: 3 additions & 0 deletions t/t1402-check-ref-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ invalid_ref 'heads/foo.lock'
valid_ref 'heads/foo@bar'
invalid_ref 'heads/v@{ation'
invalid_ref 'heads/foo\bar'
invalid_ref "$(printf 'heads/foo\t')"
invalid_ref "$(printf 'heads/foo\177')"
valid_ref "$(printf 'heads/fu\303\237')"

test_expect_success "check-ref-format --branch @{-1}" '
T=$(git write-tree) &&
Expand Down

0 comments on commit f3738c1

Please sign in to comment.