Reject pushing to invalid reference names
If a reference name is not valid according to Git's rules for the allowable syntax, or it contains "//" because a typo on the client side introduced an unnecessary slash, reject the command with an error. Bug: issue 466 Change-Id: I89d8137a89225bc31813f5870d75568e5080b059 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -404,6 +404,12 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Repository.isValidRefName(cmd.getRefName())
|
||||
|| cmd.getRefName().contains("//")) {
|
||||
reject(cmd, "not valid ref");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd.getRefName().startsWith(NEW_CHANGE)) {
|
||||
parseNewChangeCommand(cmd);
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user