]> source.dussan.org Git - gitea.git/commitdiff
Fix some issues with special chars in branch names (#3767)
authornubenum <github@nubenum.de>
Sun, 16 Sep 2018 22:28:23 +0000 (00:28 +0200)
committerLauris BH <lauris@nix.lv>
Sun, 16 Sep 2018 22:28:23 +0000 (01:28 +0300)
Signed-off-by: Robin Durner <github@nubenum.de>
12 files changed:
templates/repo/activity.tmpl
templates/repo/branch/list.tmpl
templates/repo/commits_table.tmpl
templates/repo/editor/edit.tmpl
templates/repo/header.tmpl
templates/repo/home.tmpl
templates/repo/issue/view.tmpl
templates/repo/pulls/commits.tmpl
templates/repo/pulls/files.tmpl
templates/repo/release/list.tmpl
templates/repo/settings/branches.tmpl
templates/user/dashboard/feeds.tmpl

index ed959c5b0198f72686f47f738266f1bd21c447af..19866d53d77b415e742b2a9642e592bb8d6a798b 100644 (file)
@@ -92,7 +92,7 @@
                                                <div class="ui green label">{{$.i18n.Tr "repo.activity.published_release_label"}}</div>
                                                {{.TagName}}
                                                {{if not .IsTag}}
-                                                       <a class="title has-emoji" href="{{$.Repository.HTMLURL}}/src/{{.TagName}}">{{.Title}}</a>
+                                                       <a class="title has-emoji" href="{{$.Repository.HTMLURL}}/src/{{.TagName | EscapePound}}">{{.Title}}</a>
                                                {{end}}
                                                {{TimeSinceUnix .CreatedUnix $.Lang}}
                                        </p>
index 2ef96defa2961d6ede8b47082560769d9cc89483..ce0558e92b8dc93da19458f77fe092ee48b9f25c 100644 (file)
                                                                <tr>
                                                                        <td>
                                                                        {{if .IsDeleted}}
-                                                                               <s><a href="{{$.RepoLink}}/src/branch/{{.Name}}">{{.Name}}</a></s>
+                                                                               <s><a href="{{$.RepoLink}}/src/branch/{{.Name | EscapePound}}">{{.Name}}</a></s>
                                                                                <p class="time">{{$.i18n.Tr "repo.branch.deleted_by" .DeletedBranch.DeletedBy.Name}} {{TimeSinceUnix .DeletedBranch.DeletedUnix $.i18n.Lang}}</p>
                                                                        {{else}}
-                                                                               <a href="{{$.RepoLink}}/src/branch/{{.Name}}">{{.Name}}</a>
+                                                                               <a href="{{$.RepoLink}}/src/branch/{{.Name | EscapePound}}">{{.Name}}</a>
                                                                                <p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}</p>
                                                                        </td>
                                                                        {{end}}
index ec433974c923cd7f46a1e5f02faffb30800d8480..53c2f98f4df9558b0eb196a21978f408c87bea78 100644 (file)
@@ -5,7 +5,7 @@
                </div>
                <div class="ten wide right aligned column">
                        {{if .PageIsCommits}}
-                               <form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/search">
+                               <form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL | EscapePound}}/search">
                                        <div class="ui tiny search input">
                                                <input name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" autofocus>
                                        </div>
@@ -79,4 +79,4 @@
        </div>
 {{end}}
 
-{{template "base/paginate" .}}
\ No newline at end of file
+{{template "base/paginate" .}}
index 5625ac1000a226e68173ecceca9af921a56d5b22..b08838cac8831ab4ec7f6b84053baa46a59dfd9d 100644 (file)
@@ -30,8 +30,8 @@
                                <div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff">
                                        <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>
                                        {{if not .IsNewFile}}
-                                       <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>
-                                       <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>
+                                       <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>
+                                       <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>
                                        {{end}}
                                </div>
                                <div class="ui bottom attached active tab segment" data-tab="write">
index 5312a49bec8113ba1f2c9f63d5ce8b73d6aacf0d..bf052301555b2a5f059582854d3de1978e8b1b7c 100644 (file)
@@ -48,7 +48,7 @@
        <div class="ui tabs container">
                <div class="ui tabular stackable menu navbar">
                        {{if .Repository.UnitEnabled $.UnitTypeCode}}
-                       <a class="{{if .PageIsViewCode}}active{{end}} item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL}}{{end}}">
+                       <a class="{{if .PageIsViewCode}}active{{end}} item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL | EscapePound}}{{end}}">
                                <i class="octicon octicon-code"></i> {{.i18n.Tr "repo.code"}}
                        </a>
                        {{end}}
index ce760ffae22acbe2c18447c8a81204f89f46de9c..3f9c6231a3a928a2c23276bd395d49cfa86e7b4b 100644 (file)
@@ -54,7 +54,7 @@
                <div class="ui stackable secondary menu mobile--margin-between-items mobile--no-negative-margins">
                        {{if and .PullRequestCtx.Allowed .IsViewBranch}}
                                <div class="fitted item">
-                                       <a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch}}...{{.Repository.Owner.Name}}:{{.BranchName}}">
+                                       <a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch | EscapePound}}...{{.Repository.Owner.Name}}:{{.BranchName | EscapePound}}">
                                                <button class="ui green tiny compact button"><i class="octicon octicon-git-compare"></i></button>
                                        </a>
                                </div>
index 007c0443552a0c666a79deb160485adaed43468b..70e823d3b7e8667d9253c6712d97b1aaf6392131 100644 (file)
@@ -10,7 +10,7 @@
                                {{if .PageIsIssueList}}
                                        <a class="ui green button" href="{{.RepoLink}}/issues/new">{{.i18n.Tr "repo.issues.new"}}</a>
                                {{else}}
-                                       <a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName}}...{{.PullRequestCtx.HeadInfo}}">{{.i18n.Tr "repo.pulls.new"}}</a>
+                                       <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>
                                {{end}}
                        </div>
                </div>
index 99bac62cfabfb4f2aacde376c85f8e8ec82c8e42..d084f9bc5aa04514a035ab21d88524b7e37fe4ef 100644 (file)
@@ -5,7 +5,7 @@
                <div class="navbar">
                        {{template "repo/issue/navbar" .}}
                        <div class="ui right">
-                               <a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName}}...{{.PullRequestCtx.HeadInfo}}">{{.i18n.Tr "repo.pulls.new"}}</a>
+                               <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>
                        </div>
                </div>
                <div class="ui divider"></div>
index fb46919f88e83ab0387e08ce71b2e35bcd2cfd40..b771dc37fdc3e3f94f6368792b050dcca7ea180a 100644 (file)
@@ -5,7 +5,7 @@
                <div class="navbar">
                        {{template "repo/issue/navbar" .}}
                        <div class="ui right">
-                               <a class="ui green button {{if not .PullRequestCtx.Allowed}}disabled{{end}}" href="{{.RepoLink}}/compare/{{.BranchName}}...{{.PullRequestCtx.HeadInfo}}">{{.i18n.Tr "repo.pulls.new"}}</a>
+                               <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>
                        </div>
                </div>
                <div class="ui divider"></div>
index 54cbb7b447212178749336fd9e043ef80b55ec54..7337b8ca0ed2331fbad92de6483d85d4e65ac0c6 100644 (file)
@@ -28,7 +28,7 @@
                                                                <span class="ui green label">{{$.i18n.Tr "repo.release.stable"}}</span>
                                                        {{end}}
                                                        <span class="tag text blue">
-                                                               <a href="{{$.RepoLink}}/src/tag/{{.TagName}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
+                                                               <a href="{{$.RepoLink}}/src/tag/{{.TagName | EscapePound}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
                                                        </span>
                                                        <span class="commit">
                                                                <a href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow"><i class="code icon"></i> {{ShortSha .Sha1}}</a>
                                        <div class="ui twelve wide column detail">
                                                {{if .IsTag}}
                                                        <h4>
-                                                               <a href="{{$.RepoLink}}/src/tag/{{.TagName}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
+                                                               <a href="{{$.RepoLink}}/src/tag/{{.TagName | EscapePound}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
                                                        </h4>
                                                        <div class="download">
                                                        {{if $.Repository.UnitEnabled $.UnitTypeCode}}
                                                                <a href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow"><i class="code icon"></i> {{ShortSha .Sha1}}</a>
-                                                               <a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i> ZIP</a>
-                                                               <a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><i class="octicon octicon-file-zip"></i> TAR.GZ</a>
+                                                               <a href="{{$.RepoLink}}/archive/{{.TagName | EscapePound}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i> ZIP</a>
+                                                               <a href="{{$.RepoLink}}/archive/{{.TagName | EscapePound}}.tar.gz"><i class="octicon octicon-file-zip"></i> TAR.GZ</a>
                                                        {{end}}
                                                        </div>
                                                {{else}}
                                                        <h3>
-                                                               <a href="{{$.RepoLink}}/src/tag/{{.TagName}}">{{.Title}}</a>
-                                                               {{if $.IsRepositoryWriter}}<small>(<a href="{{$.RepoLink}}/releases/edit/{{.TagName}}" rel="nofollow">{{$.i18n.Tr "repo.release.edit"}}</a>)</small>{{end}}
+                                                               <a href="{{$.RepoLink}}/src/tag/{{.TagName | EscapePound}}">{{.Title}}</a>
+                                                               {{if $.IsRepositoryWriter}}<small>(<a href="{{$.RepoLink}}/releases/edit/{{.TagName | EscapePound}}" rel="nofollow">{{$.i18n.Tr "repo.release.edit"}}</a>)</small>{{end}}
                                                        </h3>
                                                        <p class="text grey">
                                                                <span class="author">
                                                                <ul class="list">
                                                                        {{if $.Repository.UnitEnabled $.UnitTypeCode}}
                                                                        <li>
-                                                                               <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>
+                                                                               <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>
                                                                        </li>
                                                                        <li>
-                                                                               <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>
+                                                                               <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>
                                                                        </li>
                                                                        {{end}}
                                                                        {{if .Attachments}}
index 85c186771332b153dd51cc2aa93ddf277395831e..6df2517a941afded298eaf54a246189fe231ee32 100644 (file)
@@ -48,7 +48,7 @@
                                                <div class="default text">{{.i18n.Tr "repo.settings.choose_branch"}}</div>
                                                <div class="menu transition hidden" tabindex="-1" style="display: block !important;">
                                                        {{range .LeftBranches}}
-                                                               <a class="item" href="{{$.Repository.Link}}/settings/branches/{{.}}">{{.}}</a>
+                                                               <a class="item" href="{{$.Repository.Link}}/settings/branches/{{. | EscapePound}}">{{.}}</a>
                                                        {{end}}
                                                </div>
                                        </div>
@@ -62,7 +62,7 @@
                                                        {{range .ProtectedBranches}}
                                                                <tr>
                                                                        <td><div class="ui basic label blue">{{.BranchName}}</div></td>
-                                                                       <td class="right aligned"><a class="rm ui button" href="{{$.Repository.Link}}/settings/branches/{{.BranchName}}">{{$.i18n.Tr "repo.settings.edit_protected_branch"}}</a></td>
+                                                                       <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>
                                                                </tr>
                                                        {{else}}
                                                                <tr class="center aligned"><td>{{.i18n.Tr "repo.settings.no_protected_branch"}}</td></tr>
index 78950183b9b9cd0fcc75ca9418eae0abf39c725f..8bd1a80f40fef93ab7e4f2393f5c0d475d0e9c34 100644 (file)
@@ -13,8 +13,8 @@
                                                {{else if eq .GetOpType 2}}
                                                        {{$.i18n.Tr "action.rename_repo" .GetContent .GetRepoLink .ShortRepoPath | Str2html}}
                                                {{else if eq .GetOpType 5}}
-                                                       {{ $branchLink := .GetBranch | EscapePound}}
-                                                       {{$.i18n.Tr "action.commit_repo" .GetRepoLink $branchLink .GetBranch .ShortRepoPath | Str2html}}
+                                                       {{ $branchLink := .GetBranch | EscapePound | Escape}}
+                                                       {{$.i18n.Tr "action.commit_repo" .GetRepoLink $branchLink (Escape .GetBranch) .ShortRepoPath | Str2html}}
                                                {{else if eq .GetOpType 6}}
                                                        {{ $index := index .GetIssueInfos 0}}
                                                        {{$.i18n.Tr "action.create_issue" .GetRepoLink $index .ShortRepoPath | Str2html}}
@@ -24,7 +24,8 @@
                                                {{else if eq .GetOpType 8}}
                                                        {{$.i18n.Tr "action.transfer_repo" .GetContent .GetRepoLink .ShortRepoPath | Str2html}}
                                                {{else if eq .GetOpType 9}}
-                                                       {{$.i18n.Tr "action.push_tag" .GetRepoLink .GetBranch .ShortRepoPath | Str2html}}
+                                                       {{ $branchLink := .GetBranch | EscapePound | Escape}}
+                                                       {{$.i18n.Tr "action.push_tag" .GetRepoLink $branchLink .ShortRepoPath | Str2html}}
                                                {{else if eq .GetOpType 10}}
                                                        {{ $index := index .GetIssueInfos 0}}
                                                        {{$.i18n.Tr "action.comment_issue" .GetRepoLink $index .ShortRepoPath | Str2html}}