@@ -287,7 +287,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
287
287
} else if models .IsErrCommitIDDoesNotMatch (err ) {
288
288
ctx .RenderWithErr (ctx .Tr ("repo.editor.file_changed_while_editing" , ctx .Repo .RepoLink + "/compare/" + form .LastCommit + "..." + ctx .Repo .CommitID ), tplEditFile , & form )
289
289
} else if git .IsErrPushOutOfDate (err ) {
290
- ctx .RenderWithErr (ctx .Tr ("repo.editor.file_changed_while_editing" , ctx .Repo .RepoLink + "/compare/" + form .LastCommit + "..." + form .NewBranchName ), tplEditFile , & form )
290
+ ctx .RenderWithErr (ctx .Tr ("repo.editor.file_changed_while_editing" , ctx .Repo .RepoLink + "/compare/" + form .LastCommit + "..." + util . PathEscapeSegments ( form .NewBranchName ) ), tplEditFile , & form )
291
291
} else if git .IsErrPushRejected (err ) {
292
292
errPushRej := err .(* git.ErrPushRejected )
293
293
if len (errPushRej .Message ) == 0 {
@@ -319,7 +319,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
319
319
}
320
320
321
321
if form .CommitChoice == frmCommitChoiceNewBranch && ctx .Repo .Repository .UnitEnabled (models .UnitTypePullRequests ) {
322
- ctx .Redirect (ctx .Repo .RepoLink + "/compare/" + ctx .Repo .BranchName + "..." + form .NewBranchName )
322
+ ctx .Redirect (ctx .Repo .RepoLink + "/compare/" + util . PathEscapeSegments ( ctx .Repo .BranchName ) + "..." + util . PathEscapeSegments ( form .NewBranchName ) )
323
323
} else {
324
324
ctx .Redirect (ctx .Repo .RepoLink + "/src/branch/" + util .PathEscapeSegments (branchName ) + "/" + util .PathEscapeSegments (form .TreePath ))
325
325
}
@@ -500,7 +500,7 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
500
500
501
501
ctx .Flash .Success (ctx .Tr ("repo.editor.file_delete_success" , ctx .Repo .TreePath ))
502
502
if form .CommitChoice == frmCommitChoiceNewBranch && ctx .Repo .Repository .UnitEnabled (models .UnitTypePullRequests ) {
503
- ctx .Redirect (ctx .Repo .RepoLink + "/compare/" + ctx .Repo .BranchName + "..." + form .NewBranchName )
503
+ ctx .Redirect (ctx .Repo .RepoLink + "/compare/" + util . PathEscapeSegments ( ctx .Repo .BranchName ) + "..." + util . PathEscapeSegments ( form .NewBranchName ) )
504
504
} else {
505
505
treePath := filepath .Dir (ctx .Repo .TreePath )
506
506
if treePath == "." {
@@ -677,7 +677,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
677
677
branchErr := err .(models.ErrBranchAlreadyExists )
678
678
ctx .RenderWithErr (ctx .Tr ("repo.editor.branch_already_exists" , branchErr .BranchName ), tplUploadFile , & form )
679
679
} else if git .IsErrPushOutOfDate (err ) {
680
- ctx .RenderWithErr (ctx .Tr ("repo.editor.file_changed_while_editing" , ctx .Repo .RepoLink + "/compare/" + ctx .Repo .CommitID + "..." + form .NewBranchName ), tplUploadFile , & form )
680
+ ctx .RenderWithErr (ctx .Tr ("repo.editor.file_changed_while_editing" , ctx .Repo .RepoLink + "/compare/" + ctx .Repo .CommitID + "..." + util . PathEscapeSegments ( form .NewBranchName ) ), tplUploadFile , & form )
681
681
} else if git .IsErrPushRejected (err ) {
682
682
errPushRej := err .(* git.ErrPushRejected )
683
683
if len (errPushRej .Message ) == 0 {
@@ -703,7 +703,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
703
703
}
704
704
705
705
if form .CommitChoice == frmCommitChoiceNewBranch && ctx .Repo .Repository .UnitEnabled (models .UnitTypePullRequests ) {
706
- ctx .Redirect (ctx .Repo .RepoLink + "/compare/" + ctx .Repo .BranchName + "..." + form .NewBranchName )
706
+ ctx .Redirect (ctx .Repo .RepoLink + "/compare/" + util . PathEscapeSegments ( ctx .Repo .BranchName ) + "..." + util . PathEscapeSegments ( form .NewBranchName ) )
707
707
} else {
708
708
ctx .Redirect (ctx .Repo .RepoLink + "/src/branch/" + util .PathEscapeSegments (branchName ) + "/" + util .PathEscapeSegments (form .TreePath ))
709
709
}
0 commit comments