mirror of
https://github.com/go-gitea/gitea
synced 2024-11-09 11:31:34 +01:00
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>
57 lines
2.3 KiB
Handlebars
57 lines
2.3 KiB
Handlebars
{{template "base/head" .}}
|
|
<div class="page-content repository settings lfs">
|
|
{{template "repo/header" .}}
|
|
{{template "repo/settings/navbar" .}}
|
|
<div class="ui container repository file list">
|
|
{{template "base/alert" .}}
|
|
<div class="tab-size-8 non-diff-file-content">
|
|
<h4 class="ui top attached header">
|
|
<a href="{{.LFSFilesLink}}">{{.i18n.Tr "repo.settings.lfs"}}</a> / <span class="truncate sha">{{.LFSFile.Oid}}</span>
|
|
<div class="ui right">
|
|
<a class="ui blue show-panel button" href="{{.LFSFilesLink}}/find?oid={{.LFSFile.Oid}}&size={{.LFSFile.Size}}">{{$.i18n.Tr "repo.settings.lfs_findcommits"}}</a>
|
|
</div>
|
|
</h4>
|
|
<div class="ui attached table unstackable segment">
|
|
<div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsRenderedHTML}} plain-text{{else if .IsTextFile}} code-view{{end}}">
|
|
{{if .IsMarkup}}
|
|
{{if .FileContent}}{{.FileContent | Safe}}{{end}}
|
|
{{else if .IsRenderedHTML}}
|
|
<pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
|
|
{{else if not .IsTextFile}}
|
|
<div class="view-raw ui center">
|
|
{{if .IsImageFile}}
|
|
<img src="{{$.RawFileLink}}">
|
|
{{else if .IsVideoFile}}
|
|
<video controls src="{{$.RawFileLink}}">
|
|
<strong>{{.i18n.Tr "repo.video_not_supported_in_browser"}}</strong>
|
|
</video>
|
|
{{else if .IsAudioFile}}
|
|
<audio controls src="{{$.RawFileLink}}">
|
|
<strong>{{.i18n.Tr "repo.audio_not_supported_in_browser"}}</strong>
|
|
</audio>
|
|
{{else if .IsPDFFile}}
|
|
<iframe width="100%" height="600px" src="{{AppSubUrl}}/vendor/plugins/pdfjs/web/viewer.html?file={{$.RawFileLink}}"></iframe>
|
|
{{else}}
|
|
<a href="{{$.RawFileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
|
|
{{end}}
|
|
</div>
|
|
{{else if .FileSize}}
|
|
<table>
|
|
<tbody>
|
|
<tr>
|
|
{{if .IsFileTooLarge}}
|
|
<td><strong>{{.i18n.Tr "repo.file_too_large"}}</strong></td>
|
|
{{else}}
|
|
<td class="lines-num">{{.LineNums}}</td>
|
|
<td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
|
|
{{end}}
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{template "base/footer" .}}
|