mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-26 21:54:19 -04:00
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>
133 lines
4.8 KiB
Handlebars
133 lines
4.8 KiB
Handlebars
{{template "base/head" .}}
|
|
<div class="page-content repository settings edit">
|
|
{{template "repo/header" .}}
|
|
{{template "repo/settings/navbar" .}}
|
|
<div class="ui container">
|
|
{{template "base/alert" .}}
|
|
{{if .Repository.IsArchived}}
|
|
<div class="ui warning message">
|
|
{{.i18n.Tr "repo.settings.archive.tagsettings_unavailable"}}
|
|
</div>
|
|
{{else}}
|
|
<h4 class="ui top attached header">
|
|
{{.i18n.Tr "repo.settings.tags.protection"}}
|
|
</h4>
|
|
|
|
<div class="ui attached segment">
|
|
<div class="ui grid">
|
|
<div class="eight wide column">
|
|
<div class="ui segment">
|
|
<form class="ui form" action="{{.Link}}" method="post">
|
|
{{.CsrfTokenHtml}}
|
|
<div class="field">
|
|
<label>{{.i18n.Tr "repo.settings.tags.protection.pattern"}}</label>
|
|
<div id="search-tag-box" class="ui search">
|
|
<div class="ui input">
|
|
<input class="prompt" name="name_pattern" autocomplete="off" value="{{.name_pattern}}" placeholder="v*" autofocus required>
|
|
</div>
|
|
<div class="help">{{.i18n.Tr "repo.settings.tags.protection.pattern.description" | Safe}}</div>
|
|
</div>
|
|
</div>
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.tags.protection.allowed.users"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="allowlist_users" value="{{.allowlist_users}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_users"}}</div>
|
|
<div class="menu">
|
|
{{range .Users}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
{{avatar . 28 "mini"}}
|
|
{{.GetDisplayName}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{if .Owner.IsOrganization}}
|
|
<div class="whitelist field">
|
|
<label>{{.i18n.Tr "repo.settings.tags.protection.allowed.teams"}}</label>
|
|
<div class="ui multiple search selection dropdown">
|
|
<input type="hidden" name="allowlist_teams" value="{{.allowlist_teams}}">
|
|
<div class="default text">{{.i18n.Tr "repo.settings.protect_whitelist_search_teams"}}</div>
|
|
<div class="menu">
|
|
{{range .Teams}}
|
|
<div class="item" data-value="{{.ID}}">
|
|
{{svg "octicon-people"}}
|
|
{{.Name}}
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
<div class="field">
|
|
{{if .PageIsEditProtectedTag}}
|
|
<button class="ui green button">
|
|
{{$.i18n.Tr "save"}}
|
|
</button>
|
|
<a class="ui blue button" href="{{$.RepoLink}}/settings/tags">
|
|
{{$.i18n.Tr "cancel"}}
|
|
</a>
|
|
{{else}}
|
|
<button class="ui green button">
|
|
{{$.i18n.Tr "repo.settings.tags.protection.create"}}
|
|
</button>
|
|
{{end}}
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sixteen wide column">
|
|
<table class="ui single line table">
|
|
<thead>
|
|
<th>{{.i18n.Tr "repo.settings.tags.protection.pattern"}}</th>
|
|
<th>{{.i18n.Tr "repo.settings.tags.protection.allowed"}}</th>
|
|
<th></th>
|
|
</thead>
|
|
<tbody>
|
|
{{range .ProtectedTags}}
|
|
<tr>
|
|
<td><pre>{{.NamePattern}}</pre></td>
|
|
<td>
|
|
{{if or .AllowlistUserIDs (and $.Owner.IsOrganization .AllowlistTeamIDs)}}
|
|
{{$userIDs := .AllowlistUserIDs}}
|
|
{{range $.Users}}
|
|
{{if contain $userIDs .ID }}
|
|
<a class="ui basic image label" href="{{.HomeLink}}">{{avatar . 26}} {{.GetDisplayName}}</a>
|
|
{{end}}
|
|
{{end}}
|
|
{{if $.Owner.IsOrganization}}
|
|
{{$teamIDs := .AllowlistTeamIDs}}
|
|
{{range $.Teams}}
|
|
{{if contain $teamIDs .ID }}
|
|
<a class="ui basic image label" href="{{$.Owner.OrganisationLink}}/teams/{{PathEscape .LowerName}}">{{.Name}}</a>
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
{{else}}
|
|
{{$.i18n.Tr "repo.settings.tags.protection.allowed.noone"}}
|
|
{{end}}
|
|
</td>
|
|
<td class="right aligned">
|
|
<a class="ui tiny blue button" href="{{$.RepoLink}}/settings/tags/{{.ID}}">{{$.i18n.Tr "edit"}}</a>
|
|
<form class="dib" action="{{$.RepoLink}}/settings/tags/delete" method="post">
|
|
{{$.CsrfTokenHtml}}
|
|
<input type="hidden" name="id" value="{{.ID}}" />
|
|
<button class="ui tiny red button">{{$.i18n.Tr "remove"}}</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{{else}}
|
|
<tr class="center aligned"><td colspan="3">{{.i18n.Tr "repo.settings.tags.protection.none"}}</td></tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
{{template "base/footer" .}}
|