From dcf44a78f0a9a33bec35fffea1ddf75cca2fd99e Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 27 Dec 2021 16:34:54 +0800 Subject: [PATCH] fix: unvalid branch name return error --- app/services/gitea/repository/entries/create_service.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/services/gitea/repository/entries/create_service.rb b/app/services/gitea/repository/entries/create_service.rb index 5e1a4c4b3..927be6a8f 100644 --- a/app/services/gitea/repository/entries/create_service.rb +++ b/app/services/gitea/repository/entries/create_service.rb @@ -55,7 +55,12 @@ class Gitea::Repository::Entries::CreateService < Gitea::ClientService when 201 then success(json_parse!(body)) when 403 then error("你没有权限操作!") when 404 then error("你操作的链接不存在!") - when 422 then error("#{filepath}文件已存在,不能重复创建!") + when 422 + if @body[:new_branch].include?('') || @body[:new_branch].include?('\'') || @body[:new_branch].include?('^') || @body[:new_branch].include?('*') + error("不合法的分支名称!") + else + error("#{filepath}文件已存在,不能重复创建!") + end else error("系统错误!") end end