Skip to content

Commit 756eafa

Browse files
nubenumlafriks
authored andcommitted
Fix some issues with special chars in branch names (#3767)
Signed-off-by: Robin Durner <[email protected]>
1 parent acb6f8a commit 756eafa

File tree

12 files changed

+26
-25
lines changed

12 files changed

+26
-25
lines changed

templates/repo/activity.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<div class="ui green label">{{$.i18n.Tr "repo.activity.published_release_label"}}</div>
9393
{{.TagName}}
9494
{{if not .IsTag}}
95-
<a class="title has-emoji" href="{{$.Repository.HTMLURL}}/src/{{.TagName}}">{{.Title}}</a>
95+
<a class="title has-emoji" href="{{$.Repository.HTMLURL}}/src/{{.TagName | EscapePound}}">{{.Title}}</a>
9696
{{end}}
9797
{{TimeSinceUnix .CreatedUnix $.Lang}}
9898
</p>

templates/repo/branch/list.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
<tr>
3939
<td>
4040
{{if .IsDeleted}}
41-
<s><a href="{{$.RepoLink}}/src/branch/{{.Name}}">{{.Name}}</a></s>
41+
<s><a href="{{$.RepoLink}}/src/branch/{{.Name | EscapePound}}">{{.Name}}</a></s>
4242
<p class="time">{{$.i18n.Tr "repo.branch.deleted_by" .DeletedBranch.DeletedBy.Name}} {{TimeSinceUnix .DeletedBranch.DeletedUnix $.i18n.Lang}}</p>
4343
{{else}}
44-
<a href="{{$.RepoLink}}/src/branch/{{.Name}}">{{.Name}}</a>
44+
<a href="{{$.RepoLink}}/src/branch/{{.Name | EscapePound}}">{{.Name}}</a>
4545
<p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}</p>
4646
</td>
4747
{{end}}

templates/repo/commits_table.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</div>
66
<div class="ten wide right aligned column">
77
{{if .PageIsCommits}}
8-
<form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/search">
8+
<form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL | EscapePound}}/search">
99
<div class="ui tiny search input">
1010
<input name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" autofocus>
1111
</div>
@@ -79,4 +79,4 @@
7979
</div>
8080
{{end}}
8181

82-
{{template "base/paginate" .}}
82+
{{template "base/paginate" .}}

templates/repo/editor/edit.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
<div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff">
3131
<a class="active item" data-tab="write"><i class="octicon octicon-code"></i> {{if .IsNewFile}}{{.i18n.Tr "repo.editor.new_file"}}{{else}}{{.i18n.Tr "repo.editor.edit_file"}}{{end}}</a>
3232
{{if not .IsNewFile}}
33-
<a class="item" data-tab="preview" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL}}" data-preview-file-modes="{{.PreviewableFileModes}}"><i class="octicon octicon-eye"></i> {{.i18n.Tr "preview"}}</a>
34-
<a class="item" data-tab="diff" data-url="{{.RepoLink}}/_preview/{{.BranchName}}/{{.TreePath}}" data-context="{{.BranchLink}}"><i class="octicon octicon-diff"></i> {{.i18n.Tr "repo.editor.preview_changes"}}</a>
33+
<a class="item" data-tab="preview" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL | EscapePound}}" data-preview-file-modes="{{.PreviewableFileModes}}"><i class="octicon octicon-eye"></i> {{.i18n.Tr "repo.release.preview"}}</a>
34+
<a class="item" data-tab="diff" data-url="{{.RepoLink}}/_preview/{{.BranchName | EscapePound}}/{{.TreePath | EscapePound}}" data-context="{{.BranchLink}}"><i class="octicon octicon-diff"></i> {{.i18n.Tr "repo.editor.preview_changes"}}</a>
3535
{{end}}
3636
</div>
3737
<div class="ui bottom attached active tab segment" data-tab="write">

templates/repo/header.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="ui tabs container">
4949
<div class="ui tabular stackable menu navbar">
5050
{{if .Repository.UnitEnabled $.UnitTypeCode}}
51-
<a class="{{if .PageIsViewCode}}active{{end}} item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL}}{{end}}">
51+
<a class="{{if .PageIsViewCode}}active{{end}} item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL | EscapePound}}{{end}}">
5252
<i class="octicon octicon-code"></i> {{.i18n.Tr "repo.code"}}
5353
</a>
5454
{{end}}

templates/repo/home.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<div class="ui stackable secondary menu mobile--margin-between-items mobile--no-negative-margins">
5555
{{if and .PullRequestCtx.Allowed .IsViewBranch}}
5656
<div class="fitted item">
57-
<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch}}...{{.Repository.Owner.Name}}:{{.BranchName}}">
57+
<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch | EscapePound}}...{{.Repository.Owner.Name}}:{{.BranchName | EscapePound}}">
5858
<button class="ui green tiny compact button"><i class="octicon octicon-git-compare"></i></button>
5959
</a>
6060
</div>

templates/repo/issue/view.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{if .PageIsIssueList}}
1111
<a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a>
1212
{{else}}
13-
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName}}...{{.PullRequestCtx.HeadInfo}}">{{.i18n.Tr "repo.pulls.new"}}</a>
13+
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName | EscapePound}}...{{.PullRequestCtx.HeadInfo | EscapePound}}">{{.i18n.Tr "repo.pulls.new"}}</a>
1414
{{end}}
1515
</div>
1616
</div>

templates/repo/pulls/commits.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="navbar">
66
{{template "repo/issue/navbar" .}}
77
<div class="ui right">
8-
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName}}...{{.PullRequestCtx.HeadInfo}}">{{.i18n.Tr "repo.pulls.new"}}</a>
8+
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName | EscapePound}}...{{.PullRequestCtx.HeadInfo | EscapePound}}">{{.i18n.Tr "repo.pulls.new"}}</a>
99
</div>
1010
</div>
1111
<div class="ui divider"></div>

templates/repo/pulls/files.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="navbar">
66
{{template "repo/issue/navbar" .}}
77
<div class="ui right">
8-
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName}}...{{.PullRequestCtx.HeadInfo}}">{{.i18n.Tr "repo.pulls.new"}}</a>
8+
<a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName | EscapePound}}...{{.PullRequestCtx.HeadInfo | EscapePound}}">{{.i18n.Tr "repo.pulls.new"}}</a>
99
</div>
1010
</div>
1111
<div class="ui divider"></div>

templates/repo/release/list.tmpl

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<span class="ui green label">{{$.i18n.Tr "repo.release.stable"}}</span>
2929
{{end}}
3030
<span class="tag text blue">
31-
<a href="{{$.RepoLink}}/src/tag/{{.TagName}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
31+
<a href="{{$.RepoLink}}/src/tag/{{.TagName | EscapePound}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
3232
</span>
3333
<span class="commit">
3434
<a href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow"><i class="code icon"></i> {{ShortSha .Sha1}}</a>
@@ -38,19 +38,19 @@
3838
<div class="ui twelve wide column detail">
3939
{{if .IsTag}}
4040
<h4>
41-
<a href="{{$.RepoLink}}/src/tag/{{.TagName}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
41+
<a href="{{$.RepoLink}}/src/tag/{{.TagName | EscapePound}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
4242
</h4>
4343
<div class="download">
4444
{{if $.Repository.UnitEnabled $.UnitTypeCode}}
4545
<a href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow"><i class="code icon"></i> {{ShortSha .Sha1}}</a>
46-
<a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i> ZIP</a>
47-
<a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><i class="octicon octicon-file-zip"></i> TAR.GZ</a>
46+
<a href="{{$.RepoLink}}/archive/{{.TagName | EscapePound}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i> ZIP</a>
47+
<a href="{{$.RepoLink}}/archive/{{.TagName | EscapePound}}.tar.gz"><i class="octicon octicon-file-zip"></i> TAR.GZ</a>
4848
{{end}}
4949
</div>
5050
{{else}}
5151
<h3>
52-
<a href="{{$.RepoLink}}/src/tag/{{.TagName}}">{{.Title}}</a>
53-
{{if $.IsRepositoryWriter}}<small>(<a href="{{$.RepoLink}}/releases/edit/{{.TagName}}" rel="nofollow">{{$.i18n.Tr "repo.release.edit"}}</a>)</small>{{end}}
52+
<a href="{{$.RepoLink}}/src/tag/{{.TagName | EscapePound}}">{{.Title}}</a>
53+
{{if $.IsRepositoryWriter}}<small>(<a href="{{$.RepoLink}}/releases/edit/{{.TagName | EscapePound}}" rel="nofollow">{{$.i18n.Tr "repo.release.edit"}}</a>)</small>{{end}}
5454
</h3>
5555
<p class="text grey">
5656
<span class="author">
@@ -68,10 +68,10 @@
6868
<ul class="list">
6969
{{if $.Repository.UnitEnabled $.UnitTypeCode}}
7070
<li>
71-
<a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><strong><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (ZIP)</strong></a>
71+
<a href="{{$.RepoLink}}/archive/{{.TagName | EscapePound}}.zip" rel="nofollow"><strong><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (ZIP)</strong></a>
7272
</li>
7373
<li>
74-
<a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><strong><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (TAR.GZ)</strong></a>
74+
<a href="{{$.RepoLink}}/archive/{{.TagName | EscapePound}}.tar.gz"><strong><i class="octicon octicon-file-zip"></i> {{$.i18n.Tr "repo.release.source_code"}} (TAR.GZ)</strong></a>
7575
</li>
7676
{{end}}
7777
{{if .Attachments}}

templates/repo/settings/branches.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<div class="default text">{{.i18n.Tr "repo.settings.choose_branch"}}</div>
4949
<div class="menu transition hidden" tabindex="-1" style="display: block !important;">
5050
{{range .LeftBranches}}
51-
<a class="item" href="{{$.Repository.Link}}/settings/branches/{{.}}">{{.}}</a>
51+
<a class="item" href="{{$.Repository.Link}}/settings/branches/{{. | EscapePound}}">{{.}}</a>
5252
{{end}}
5353
</div>
5454
</div>
@@ -62,7 +62,7 @@
6262
{{range .ProtectedBranches}}
6363
<tr>
6464
<td><div class="ui basic label blue">{{.BranchName}}</div></td>
65-
<td class="right aligned"><a class="rm ui button" href="{{$.Repository.Link}}/settings/branches/{{.BranchName}}">{{$.i18n.Tr "repo.settings.edit_protected_branch"}}</a></td>
65+
<td class="right aligned"><a class="rm ui button" href="{{$.Repository.Link}}/settings/branches/{{.BranchName | EscapePound}}">{{$.i18n.Tr "repo.settings.edit_protected_branch"}}</a></td>
6666
</tr>
6767
{{else}}
6868
<tr class="center aligned"><td>{{.i18n.Tr "repo.settings.no_protected_branch"}}</td></tr>

templates/user/dashboard/feeds.tmpl

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
{{else if eq .GetOpType 2}}
1414
{{$.i18n.Tr "action.rename_repo" .GetContent .GetRepoLink .ShortRepoPath | Str2html}}
1515
{{else if eq .GetOpType 5}}
16-
{{ $branchLink := .GetBranch | EscapePound}}
17-
{{$.i18n.Tr "action.commit_repo" .GetRepoLink $branchLink .GetBranch .ShortRepoPath | Str2html}}
16+
{{ $branchLink := .GetBranch | EscapePound | Escape}}
17+
{{$.i18n.Tr "action.commit_repo" .GetRepoLink $branchLink (Escape .GetBranch) .ShortRepoPath | Str2html}}
1818
{{else if eq .GetOpType 6}}
1919
{{ $index := index .GetIssueInfos 0}}
2020
{{$.i18n.Tr "action.create_issue" .GetRepoLink $index .ShortRepoPath | Str2html}}
@@ -24,7 +24,8 @@
2424
{{else if eq .GetOpType 8}}
2525
{{$.i18n.Tr "action.transfer_repo" .GetContent .GetRepoLink .ShortRepoPath | Str2html}}
2626
{{else if eq .GetOpType 9}}
27-
{{$.i18n.Tr "action.push_tag" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
27+
{{ $branchLink := .GetBranch | EscapePound | Escape}}
28+
{{$.i18n.Tr "action.push_tag" .GetRepoLink $branchLink .ShortRepoPath | Str2html}}
2829
{{else if eq .GetOpType 10}}
2930
{{ $index := index .GetIssueInfos 0}}
3031
{{$.i18n.Tr "action.comment_issue" .GetRepoLink $index .ShortRepoPath | Str2html}}

0 commit comments

Comments
 (0)