mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 22:15:51 +01:00
(refs #120)URL encode branch name except '/'.
This commit is contained in:
@@ -67,6 +67,11 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
|||||||
.replaceAll("\\[user:([^\\s]+?)\\]" , s"""<a href="${context.path}/$$1">$$1</a>""")
|
.replaceAll("\\[user:([^\\s]+?)\\]" , s"""<a href="${context.path}/$$1">$$1</a>""")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL encode except '/'.
|
||||||
|
*/
|
||||||
|
def encodeBranchName(value: String): String = StringUtil.urlEncode(value).replace("%2F", "/")
|
||||||
|
|
||||||
def urlEncode(value: String): String = StringUtil.urlEncode(value)
|
def urlEncode(value: String): String = StringUtil.urlEncode(value)
|
||||||
|
|
||||||
def urlEncode(value: Option[String]): String = value.map(urlEncode).getOrElse("")
|
def urlEncode(value: Option[String]): String = value.map(urlEncode).getOrElse("")
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
}
|
}
|
||||||
@helper.html.dropdown(originId, "base") {
|
@helper.html.dropdown(originId, "base") {
|
||||||
@originRepository.branchList.map { branch =>
|
@originRepository.branchList.map { branch =>
|
||||||
<li><a href="#" class="origin-branch" data-name="@branch">@helper.html.checkicon(branch == originId) @branch</a></li>
|
<li><a href="#" class="origin-branch" data-name="@encodeBranchName(branch)">@helper.html.checkicon(branch == originId) @branch</a></li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
}
|
}
|
||||||
@helper.html.dropdown(forkedId, "compare") {
|
@helper.html.dropdown(forkedId, "compare") {
|
||||||
@forkedRepository.branchList.map { branch =>
|
@forkedRepository.branchList.map { branch =>
|
||||||
<li><a href="#" class="forked-branch" data-name="@branch">@helper.html.checkicon(branch == forkedId) @branch</a></li>
|
<li><a href="#" class="forked-branch" data-name="@encodeBranchName(branch)">@helper.html.checkicon(branch == forkedId) @branch</a></li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
@html.header("code", repository)
|
@html.header("code", repository)
|
||||||
@tab(branch, repository, "files")
|
@tab(branch, repository, "files")
|
||||||
<div class="head">
|
<div class="head">
|
||||||
<a href="@url(repository)/tree/@branch">@repository.name</a> /
|
<a href="@url(repository)/tree/@encodeBranchName(branch)">@repository.name</a> /
|
||||||
@pathList.zipWithIndex.map { case (section, i) =>
|
@pathList.zipWithIndex.map { case (section, i) =>
|
||||||
@if(i == pathList.length - 1){
|
@if(i == pathList.length - 1){
|
||||||
@section
|
@section
|
||||||
} else {
|
} else {
|
||||||
<a href="@url(repository)/tree/@branch/@pathList.take(i + 1).mkString("/")">@section</a> /
|
<a href="@url(repository)/tree/@encodeBranchName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="btn-group pull-right">
|
<div class="btn-group pull-right">
|
||||||
<a class="btn btn-mini" href="?raw=true">Raw</a>
|
<a class="btn btn-mini" href="?raw=true">Raw</a>
|
||||||
<a class="btn btn-mini" href="@url(repository)/commits/@branch/@pathList.mkString("/")">History</a>
|
<a class="btn btn-mini" href="@url(repository)/commits/@encodeBranchName(branch)/@pathList.mkString("/")">History</a>
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
@branchInfo.map { case (branchName, latestUpdateDate) =>
|
@branchInfo.map { case (branchName, latestUpdateDate) =>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="@url(repository)/tree/@branchName">@branchName</a>
|
<a href="@url(repository)/tree/@encodeBranchName(branchName)">@branchName</a>
|
||||||
@*
|
@*
|
||||||
<a href="#" class="btn btn-danger btn-mini">Delete branch</a>
|
<a href="#" class="btn btn-danger btn-mini">Delete branch</a>
|
||||||
*@
|
*@
|
||||||
@@ -28,10 +28,10 @@
|
|||||||
@if(repository.repository.defaultBranch == branchName){
|
@if(repository.repository.defaultBranch == branchName){
|
||||||
Base branch
|
Base branch
|
||||||
} else {
|
} else {
|
||||||
<a href="@url(repository)/compare/@{repository.repository.defaultBranch}...@branchName">to @{repository.repository.defaultBranch}</a>
|
<a href="@url(repository)/compare/@{encodeBranchName(repository.repository.defaultBranch)}...@{encodeBranchName(branchName)}">to @{repository.repository.defaultBranch}</a>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td><a href="@url(repository)/archive/@{branchName}.zip">ZIP</a></td>
|
<td><a href="@url(repository)/archive/@{encodeBranchName(branchName)}.zip">ZIP</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<span class="muted">
|
<span class="muted">
|
||||||
<img src="@assets/common/images/branch.png"/>
|
<img src="@assets/common/images/branch.png"/>
|
||||||
@branches.zipWithIndex.map { case (branch, i) =>
|
@branches.zipWithIndex.map { case (branch, i) =>
|
||||||
<a href="@url(repository)/tree/@branch" class="branch" id="branch-@i">@branch</a>
|
<a href="@url(repository)/tree/@encodeBranchName(branch)" class="branch" id="branch-@i">@branch</a>
|
||||||
}
|
}
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,16 @@
|
|||||||
@tab(branch, repository, if(pathList.isEmpty) "commits" else "files")
|
@tab(branch, repository, if(pathList.isEmpty) "commits" else "files")
|
||||||
<div class="head">
|
<div class="head">
|
||||||
@if(pathList.isEmpty){
|
@if(pathList.isEmpty){
|
||||||
<a href="@url(repository)/tree/@branch">@repository.name</a> / Commit History
|
<a href="@url(repository)/tree/@encodeBranchName(branch)">@repository.name</a> / Commit History
|
||||||
}
|
}
|
||||||
@if(pathList.nonEmpty){
|
@if(pathList.nonEmpty){
|
||||||
<span class="muted">History for</span>
|
<span class="muted">History for</span>
|
||||||
<a href="@url(repository)/tree/@branch">@repository.name</a> /
|
<a href="@url(repository)/tree/@encodeBranchName(branch)">@repository.name</a> /
|
||||||
@pathList.zipWithIndex.map { case (section, i) =>
|
@pathList.zipWithIndex.map { case (section, i) =>
|
||||||
@if(i == pathList.length - 1){
|
@if(i == pathList.length - 1){
|
||||||
@section
|
@section
|
||||||
} else {
|
} else {
|
||||||
<a href="@url(repository)/tree/@branch/@pathList.take(i + 1).mkString("/")">@section</a> /
|
<a href="@url(repository)/tree/@encodeBranchName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,12 @@
|
|||||||
<div class="head">
|
<div class="head">
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@defining(repository.commitCount){ commitCount =>
|
@defining(repository.commitCount){ commitCount =>
|
||||||
<a href="@url(repository)/commits/@branch">@if(commitCount > 1000){ @commitCount+ } else { @commitCount } @plural(commitCount, "commit")</a>
|
<a href="@url(repository)/commits/@encodeBranchName(branch)">@if(commitCount > 1000){ @commitCount+ } else { @commitCount } @plural(commitCount, "commit")</a>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<a href="@url(repository)/tree/@branch">@repository.name</a> /
|
<a href="@url(repository)/tree/@encodeBranchName(branch)">@repository.name</a> /
|
||||||
@pathList.zipWithIndex.map { case (section, i) =>
|
@pathList.zipWithIndex.map { case (section, i) =>
|
||||||
<a href="@url(repository)/tree/@branch/@pathList.take(i + 1).mkString("/")">@section</a> /
|
<a href="@url(repository)/tree/@encodeBranchName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
@if(pathList.size > 0){
|
@if(pathList.size > 0){
|
||||||
<tr>
|
<tr>
|
||||||
<td width="16"></td>
|
<td width="16"></td>
|
||||||
<td><a href="@url(repository)@if(pathList.size > 1){/tree/@branch/@pathList.init.mkString("/")}">..</a></td>
|
<td><a href="@url(repository)@if(pathList.size > 1){/tree/@encodeBranchName(branch)/@pathList.init.mkString("/")}">..</a></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -62,9 +62,9 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@if(file.isDirectory){
|
@if(file.isDirectory){
|
||||||
<a href="@url(repository)/tree@{(branch :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
<a href="@url(repository)/tree@{(encodeBranchName(branch) :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
||||||
} else {
|
} else {
|
||||||
<a href="@url(repository)/blob@{(branch :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
<a href="@url(repository)/blob@{(encodeBranchName(branch) :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td>@datetime(file.time)</td>
|
<td>@datetime(file.time)</td>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
style = "margin-right: 20px;"
|
style = "margin-right: 20px;"
|
||||||
){
|
){
|
||||||
@repository.branchList.map { branch =>
|
@repository.branchList.map { branch =>
|
||||||
<li><a href="@url(repository)/@if(active=="commits"){commits} else {tree}/@branch">@helper.html.checkicon(id == branch) @branch</a></li>
|
<li><a href="@url(repository)/@if(active=="commits"){commits} else {tree}/@encodeBranchName(branch)">@helper.html.checkicon(id == branch) @branch</a></li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user