mirror of https://github.com/go-gitea/gitea.git
enforce maxlength in frontend (#29389)
Set maxlength attribute in frontend to long file-name ![image](https://github.com/go-gitea/gitea/assets/72873130/15111614-55ab-4583-acb2-15c25997601d) ![image](https://github.com/go-gitea/gitea/assets/72873130/4105ddd8-4973-4da8-b3ab-4cfae1b45554) (same for branch-name and commit-summary)
This commit is contained in:
parent
d2f6588b66
commit
756b952c52
|
@ -9,7 +9,7 @@
|
||||||
{{ctx.Locale.Tr "repo.editor.commit_changes"}}
|
{{ctx.Locale.Tr "repo.editor.commit_changes"}}
|
||||||
{{- end}}</h3>
|
{{- end}}</h3>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<input name="commit_summary" placeholder="{{if .PageIsDelete}}{{ctx.Locale.Tr "repo.editor.delete" .TreePath}}{{else if .PageIsUpload}}{{ctx.Locale.Tr "repo.editor.upload_files_to_dir" .TreePath}}{{else if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.add_tmpl"}}{{else if .PageIsPatch}}{{ctx.Locale.Tr "repo.editor.patch"}}{{else}}{{ctx.Locale.Tr "repo.editor.update" .TreePath}}{{end}}" value="{{.commit_summary}}" autofocus>
|
<input name="commit_summary" maxlength="100" placeholder="{{if .PageIsDelete}}{{ctx.Locale.Tr "repo.editor.delete" .TreePath}}{{else if .PageIsUpload}}{{ctx.Locale.Tr "repo.editor.upload_files_to_dir" .TreePath}}{{else if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.add_tmpl"}}{{else if .PageIsPatch}}{{ctx.Locale.Tr "repo.editor.patch"}}{{else}}{{ctx.Locale.Tr "repo.editor.update" .TreePath}}{{end}}" value="{{.commit_summary}}" autofocus>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<textarea name="commit_message" placeholder="{{ctx.Locale.Tr "repo.editor.commit_message_desc"}}" rows="5">{{.commit_message}}</textarea>
|
<textarea name="commit_message" placeholder="{{ctx.Locale.Tr "repo.editor.commit_message_desc"}}" rows="5">{{.commit_message}}</textarea>
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
<div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}gt-hidden{{end}}">
|
<div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}gt-hidden{{end}}">
|
||||||
<div class="new-branch-name-input field {{if .Err_NewBranchName}}error{{end}}">
|
<div class="new-branch-name-input field {{if .Err_NewBranchName}}error{{end}}">
|
||||||
{{svg "octicon-git-branch"}}
|
{{svg "octicon-git-branch"}}
|
||||||
<input type="text" name="new_branch_name" value="{{.new_branch_name}}" class="input-contrast gt-mr-2 js-quick-pull-new-branch-name" placeholder="{{ctx.Locale.Tr "repo.editor.new_branch_name_desc"}}" {{if eq .commit_choice "commit-to-new-branch"}}required{{end}} title="{{ctx.Locale.Tr "repo.editor.new_branch_name"}}">
|
<input type="text" name="new_branch_name" maxlength="100" value="{{.new_branch_name}}" class="input-contrast gt-mr-2 js-quick-pull-new-branch-name" placeholder="{{ctx.Locale.Tr "repo.editor.new_branch_name_desc"}}" {{if eq .commit_choice "commit-to-new-branch"}}required{{end}} title="{{ctx.Locale.Tr "repo.editor.new_branch_name"}}">
|
||||||
<span class="text-muted js-quick-pull-normalization-info"></span>
|
<span class="text-muted js-quick-pull-normalization-info"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
{{range $i, $v := .TreeNames}}
|
{{range $i, $v := .TreeNames}}
|
||||||
<div class="breadcrumb-divider">/</div>
|
<div class="breadcrumb-divider">/</div>
|
||||||
{{if eq $i $l}}
|
{{if eq $i $l}}
|
||||||
<input id="file-name" value="{{$v}}" placeholder="{{ctx.Locale.Tr "repo.editor.name_your_file"}}" data-editorconfig="{{$.EditorconfigJson}}" required autofocus>
|
<input id="file-name" maxlength="500" value="{{$v}}" placeholder="{{ctx.Locale.Tr "repo.editor.name_your_file"}}" data-editorconfig="{{$.EditorconfigJson}}" required autofocus>
|
||||||
<span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span>
|
<span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>
|
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a>
|
<a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a>
|
||||||
<span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span>
|
<span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span>
|
||||||
<input type="hidden" id="tree_path" name="tree_path" value="" required>
|
<input type="hidden" id="tree_path" name="tree_path" value="" required>
|
||||||
<input id="file-name" type="hidden" value="diff.patch">
|
<input id="file-name" maxlength="500" type="hidden" value="diff.patch">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
{{range $i, $v := .TreeNames}}
|
{{range $i, $v := .TreeNames}}
|
||||||
<div class="breadcrumb-divider">/</div>
|
<div class="breadcrumb-divider">/</div>
|
||||||
{{if eq $i $l}}
|
{{if eq $i $l}}
|
||||||
<input type="text" id="file-name" value="{{$v}}" placeholder="{{ctx.Locale.Tr "repo.editor.add_subdir"}}" autofocus>
|
<input type="text" id="file-name" maxlength="500" value="{{$v}}" placeholder="{{ctx.Locale.Tr "repo.editor.add_subdir"}}" autofocus>
|
||||||
<span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span>
|
<span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>
|
<span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span>
|
||||||
|
|
|
@ -2,13 +2,14 @@ import {encode, decode} from 'uint8-to-base64';
|
||||||
|
|
||||||
// transform /path/to/file.ext to file.ext
|
// transform /path/to/file.ext to file.ext
|
||||||
export function basename(path = '') {
|
export function basename(path = '') {
|
||||||
return path ? path.replace(/^.*\//, '') : '';
|
const lastSlashIndex = path.lastIndexOf('/');
|
||||||
|
return lastSlashIndex < 0 ? path : path.substring(lastSlashIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// transform /path/to/file.ext to .ext
|
// transform /path/to/file.ext to .ext
|
||||||
export function extname(path = '') {
|
export function extname(path = '') {
|
||||||
const [_, ext] = /.+(\.[^.]+)$/.exec(path) || [];
|
const lastPointIndex = path.lastIndexOf('.');
|
||||||
return ext || '';
|
return lastPointIndex < 0 ? '' : path.substring(lastPointIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test whether a variable is an object
|
// test whether a variable is an object
|
||||||
|
|
Loading…
Reference in New Issue