mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-14 22:59:29 +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>
80 lines
3.8 KiB
Handlebars
80 lines
3.8 KiB
Handlebars
{{template "base/head" .}}
|
|
<div class="page-content repository file editor edit">
|
|
{{template "repo/header" .}}
|
|
<div class="ui container">
|
|
{{template "base/alert" .}}
|
|
<form class="ui edit form" method="post">
|
|
{{.CsrfTokenHtml}}
|
|
<input type="hidden" name="last_commit" value="{{.last_commit}}">
|
|
<input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}">
|
|
<div class="ui secondary menu">
|
|
<div class="fitted item treepath">
|
|
<div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}">
|
|
<a class="section" href="{{$.BranchLink}}">{{.Repository.Name}}</a>
|
|
{{ $n := len .TreeNames}}
|
|
{{ $l := Subtract $n 1}}
|
|
{{range $i, $v := .TreeNames}}
|
|
<div class="divider"> / </div>
|
|
{{if eq $i $l}}
|
|
<input id="file-name" value="{{$v}}" placeholder="{{$.i18n.Tr "repo.editor.name_your_file"}}" data-editorconfig="{{$.Editorconfig}}" required autofocus>
|
|
<span class="poping up" data-content="{{$.i18n.Tr "repo.editor.filename_help"}}" data-position="bottom center" data-variation="tiny inverted">{{svg "octicon-info"}}</span>
|
|
{{else}}
|
|
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>
|
|
{{end}}
|
|
{{end}}
|
|
<span>{{.i18n.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}{{if not .IsNewFile}}/{{PathEscapeSegments .TreePath}}{{end}}">{{.i18n.Tr "repo.editor.cancel_lower"}}</a></span>
|
|
<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff">
|
|
<a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{.i18n.Tr "repo.editor.new_file"}}{{else}}{{.i18n.Tr "repo.editor.edit_file"}}{{end}}</a>
|
|
{{if not .IsNewFile}}
|
|
<a class="item" data-tab="preview" data-url="{{.Repository.APIURL}}/markdown" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL}}" data-preview-file-modes="{{.PreviewableFileModes}}" data-markdown-mode="gfm">{{svg "octicon-eye"}} {{.i18n.Tr "preview"}}</a>
|
|
<a class="item" data-tab="diff" data-url="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}" data-context="{{.BranchLink}}">{{svg "octicon-diff"}} {{.i18n.Tr "repo.editor.preview_changes"}}</a>
|
|
{{end}}
|
|
</div>
|
|
<div class="ui bottom attached active tab segment" data-tab="write">
|
|
<textarea id="edit_area" name="content" class="hide" data-id="repo-{{.Repository.Name}}-{{.TreePath}}"
|
|
data-url="{{.Repository.APIURL}}/markdown"
|
|
data-context="{{.RepoLink}}"
|
|
data-markdown-file-exts="{{.MarkdownFileExts}}"
|
|
data-line-wrap-extensions="{{.LineWrapExtensions}}">
|
|
{{.FileContent}}</textarea>
|
|
<div class="editor-loading is-loading"></div>
|
|
</div>
|
|
<div class="ui bottom attached tab segment markup" data-tab="preview">
|
|
{{.i18n.Tr "loading"}}
|
|
</div>
|
|
<div class="ui bottom attached tab segment diff edit-diff" data-tab="diff">
|
|
{{.i18n.Tr "loading"}}
|
|
</div>
|
|
</div>
|
|
{{template "repo/editor/commit_form" .}}
|
|
</form>
|
|
</div>
|
|
|
|
|
|
<div class="ui small basic modal" id="edit-empty-content-modal">
|
|
<div class="ui icon header">
|
|
<i class="file icon"></i>
|
|
{{.i18n.Tr "repo.editor.commit_empty_file_header"}}
|
|
</div>
|
|
<div class="center content">
|
|
<p>{{.i18n.Tr "repo.editor.commit_empty_file_text"}}</p>
|
|
</div>
|
|
<div class="actions">
|
|
<div class="ui red basic cancel inverted button">
|
|
<i class="remove icon"></i>
|
|
{{.i18n.Tr "repo.editor.cancel"}}
|
|
</div>
|
|
<div class="ui green basic ok inverted button">
|
|
<i class="save icon"></i>
|
|
{{.i18n.Tr "repo.editor.commit_changes"}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
{{template "base/footer" .}}
|