forked from Shiloh/githaven
bbffcc3aec
There are multiple places where Gitea does not properly escape URLs that it is building and there are multiple places where it builds urls when there is already a simpler function available to use this. This is an extensive PR attempting to fix these issues. 1. The first commit in this PR looks through all href, src and links in the Gitea codebase and has attempted to catch all the places where there is potentially incomplete escaping. 2. Whilst doing this we will prefer to use functions that create URLs over recreating them by hand. 3. All uses of strings should be directly escaped - even if they are not currently expected to contain escaping characters. The main benefit to doing this will be that we can consider relaxing the constraints on user names and reponames in future. 4. The next commit looks at escaping in the wiki and re-considers the urls that are used there. Using the improved escaping here wiki files containing '/'. (This implementation will currently still place all of the wiki files the root directory of the repo but this would not be difficult to change.) 5. The title generation in feeds is now properly escaped. 6. EscapePound is no longer needed - urls should be PathEscaped / QueryEscaped as necessary but then re-escaped with Escape when creating html with locales Signed-off-by: Andrew Thornton <art27@cantab.net> Signed-off-by: Andrew Thornton <art27@cantab.net>
85 lines
4.6 KiB
Handlebars
85 lines
4.6 KiB
Handlebars
{{$release := .release}}
|
|
{{$showBranchesInDropdown := not .root.HideBranchesInDropdown}}
|
|
<div class="fitted item choose reference{{if not $release}} mr-1{{end}}">
|
|
<div class="ui floating filter dropdown custom" data-can-create-branch="{{.root.CanCreateBranch}}" data-no-results="{{.root.i18n.Tr "repo.pulls.no_results"}}">
|
|
<div class="ui basic small compact button" @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible">
|
|
<span class="text">
|
|
{{if $release}}
|
|
{{.root.i18n.Tr "repo.release.compare"}}
|
|
{{else}}
|
|
{{svg "octicon-git-branch"}}
|
|
{{if .root.IsViewBranch}}{{.root.i18n.Tr "repo.branch"}}{{else}}{{.root.i18n.Tr "repo.tree"}}{{end}}:
|
|
<strong>{{if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.BranchName}}{{end}}</strong>
|
|
{{end}}
|
|
</span>
|
|
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
|
</div>
|
|
<div class="data" style="display: none" data-mode="{{if .root.IsViewTag}}tags{{else}}branches{{end}}">
|
|
{{if $showBranchesInDropdown}}
|
|
{{range .root.Branches}}
|
|
<div class="item branch {{if eq $.root.BranchName .}}selected{{end}}" data-url="{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{PathEscapeSegments .}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}">{{.}}</div>
|
|
{{end}}
|
|
{{end}}
|
|
{{range .root.Tags}}
|
|
{{if $release}}
|
|
<div class="item tag {{if eq $release.TagName .}}selected{{end}}" data-url="{{$.root.RepoLink}}/compare/{{PathEscapeSegments .}}...{{if $release.IsDraft}}{{PathEscapeSegments $release.Target}}{{else}}{{if $release.TagName}}{{PathEscapeSegments $release.TagName}}{{else}}{{PathEscapeSegments $release.Sha1}}{{end}}{{end}}">{{.}}</div>
|
|
{{else}}
|
|
<div class="item tag {{if eq $.root.BranchName .}}selected{{end}}" data-url="{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{PathEscapeSegments .}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}">{{.}}</div>
|
|
{{end}}
|
|
{{end}}
|
|
</div>
|
|
<div class="menu transition" :class="{visible: menuVisible}" v-if="menuVisible" v-cloak>
|
|
<div class="ui icon search input">
|
|
<i class="icon df ac jc m-0">{{svg "octicon-filter" 16}}</i>
|
|
<input name="search" ref="searchField" autocomplete="off" v-model="searchTerm" @keydown="keydown($event)" placeholder="{{if $showBranchesInDropdown}}{{.root.i18n.Tr "repo.filter_branch_and_tag"}}{{else}}{{.root.i18n.Tr "repo.find_tag"}}{{end}}...">
|
|
</div>
|
|
{{if $showBranchesInDropdown}}
|
|
<div class="header branch-tag-choice">
|
|
<div class="ui grid">
|
|
<div class="two column row">
|
|
<a class="reference column" href="#" @click="createTag = false; mode = 'branches'; focusSearchField()">
|
|
<span class="text" :class="{black: mode == 'branches'}">
|
|
{{svg "octicon-git-branch" 16 "mr-2"}}{{.root.i18n.Tr "repo.branches"}}
|
|
</span>
|
|
</a>
|
|
<a class="reference column" href="#" @click="createTag = true; mode = 'tags'; focusSearchField()">
|
|
<span class="text" :class="{black: mode == 'tags'}">
|
|
{{svg "octicon-tag" 16 "mr-2"}}{{.root.i18n.Tr "repo.tags"}}
|
|
</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
<div class="scrolling menu" ref="scrollContainer">
|
|
<div v-for="(item, index) in filteredItems" :key="item.name" class="item" :class="{selected: item.selected, active: active == index}" @click="selectItem(item)" :ref="'listItem' + index">${ item.name }</div>
|
|
<div class="item" v-if="showCreateNewBranch" :class="{active: active == filteredItems.length}" :ref="'listItem' + filteredItems.length">
|
|
<a href="#" @click="createNewBranch()">
|
|
<div v-show="createTag">
|
|
<i class="reference tags icon"></i>
|
|
{{.root.i18n.Tr "repo.tag.create_tag" `${ searchTerm }` | Safe}}
|
|
</div>
|
|
<div v-show="!createTag">
|
|
{{svg "octicon-git-branch"}}
|
|
{{.root.i18n.Tr "repo.branch.create_branch" `${ searchTerm }` | Safe}}
|
|
</div>
|
|
<div class="text small">
|
|
{{if or .root.IsViewBranch $release}}
|
|
{{.root.i18n.Tr "repo.branch.create_from" .root.BranchName}}
|
|
{{else}}
|
|
{{.root.i18n.Tr "repo.branch.create_from" (ShortSha .root.BranchName)}}
|
|
{{end}}
|
|
</div>
|
|
</a>
|
|
<form ref="newBranchForm" action="{{.root.RepoLink}}/branches/_new/{{.root.BranchNameSubURL}}" method="post">
|
|
{{.root.CsrfTokenHtml}}
|
|
<input type="hidden" name="new_branch_name" v-model="searchTerm">
|
|
<input type="hidden" name="create_tag" v-model="createTag">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="message" v-if="showNoResults">${ noResults }</div>
|
|
</div>
|
|
</div>
|
|
</div>
|