From ac390d28b8d3b345d3a21f2c8f1da3119209a2cf Mon Sep 17 00:00:00 2001
From: Odin Ugedal <odin@ugedal.com>
Date: Tue, 15 Mar 2016 11:31:35 +0100
Subject: [PATCH 1/2] Fix problems with '#' in branchname

Add proper escaping of '#' in branchname in compare when doing pull
requests. This addresses issue #2822.
---
 templates/repo/pulls/compare.tmpl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/repo/pulls/compare.tmpl b/templates/repo/pulls/compare.tmpl
index 0d7b6f9b5..7069fe3f0 100644
--- a/templates/repo/pulls/compare.tmpl
+++ b/templates/repo/pulls/compare.tmpl
@@ -21,7 +21,7 @@
 						</div>
 						<div class="scrolling menu">
 							{{range .Branches}}
-								<div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{.}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{$.HeadBranch}}">{{.}}</div>
+								<div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{EscapePound .}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{EscapePound $.HeadBranch}}">{{.}}</div>
 							{{end}}
 						</div>
 					</div>
@@ -39,7 +39,7 @@
 						</div>
 						<div class="scrolling menu">
 							{{range .HeadBranches}}
-								<div class="{{if eq $.HeadBranch .}}selected{{end}} item" data-url="{{$.RepoLink}}/compare/{{$.BaseBranch}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{.}}">{{.}}</div>
+								<div class="{{if eq $.HeadBranch .}}selected{{end}} item" data-url="{{$.RepoLink}}/compare/{{EscapePound $.BaseBranch}}...{{if not $.PullRequestCtx.SameRepo}}{{$.HeadUser.Name}}:{{end}}{{EscapePound .}}">{{.}}</div>
 							{{end}}
 						</div>
 					</div>

From c9321550e0e281c0ceebaae8db35b2bc796a71bd Mon Sep 17 00:00:00 2001
From: Odin Ugedal <odin@ugedal.com>
Date: Tue, 15 Mar 2016 11:56:49 +0100
Subject: [PATCH 2/2] Add prorper escaping of url in issue form

---
 templates/repo/issue/new_form.tmpl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl
index b77cfb2c7..77c6d126d 100644
--- a/templates/repo/issue/new_form.tmpl
+++ b/templates/repo/issue/new_form.tmpl
@@ -1,4 +1,4 @@
-<form class="ui comment form grid" action="{{.Link}}" method="post">
+<form class="ui comment form grid" action="{{EscapePound .Link}}" method="post">
 	{{.CsrfTokenHtml}}
 	{{if .Flash}}
 		<div class="sixteen wide column">