Skip to content

Commit 8351172

Browse files
authored
Limit length of repo description and repo url input fields (#21119)
Both allow only limited characters. If you input more, you will get a error message. So it make sense to limit the characters of the input fields. Slightly relax the MaxSize of repo's Description and Website
1 parent bdc4c4c commit 8351172

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

modules/structs/repo.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ type CreateRepoOption struct {
111111
// unique: true
112112
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
113113
// Description of the repository to create
114-
Description string `json:"description" binding:"MaxSize(255)"`
114+
Description string `json:"description" binding:"MaxSize(2048)"`
115115
// Whether the repository is private
116116
Private bool `json:"private"`
117117
// Label-Set to use
@@ -140,9 +140,9 @@ type EditRepoOption struct {
140140
// unique: true
141141
Name *string `json:"name,omitempty" binding:"OmitEmpty;AlphaDashDot;MaxSize(100);"`
142142
// a short description of the repository.
143-
Description *string `json:"description,omitempty" binding:"MaxSize(255)"`
143+
Description *string `json:"description,omitempty" binding:"MaxSize(2048)"`
144144
// a URL with more information about the repository.
145-
Website *string `json:"website,omitempty" binding:"MaxSize(255)"`
145+
Website *string `json:"website,omitempty" binding:"MaxSize(1024)"`
146146
// either `true` to make the repository private or `false` to make it public.
147147
// Note: you will get a 422 error if the organization restricts changing repository visibility to organization
148148
// owners and a non-owner tries to change the value of private.
@@ -208,7 +208,7 @@ type GenerateRepoOption struct {
208208
// Default branch of the new repository
209209
DefaultBranch string `json:"default_branch"`
210210
// Description of the repository to create
211-
Description string `json:"description" binding:"MaxSize(255)"`
211+
Description string `json:"description" binding:"MaxSize(2048)"`
212212
// Whether the repository is private
213213
Private bool `json:"private"`
214214
// include git content of default branch in template repo
@@ -316,7 +316,7 @@ type MigrateRepoOptions struct {
316316
LFS bool `json:"lfs"`
317317
LFSEndpoint string `json:"lfs_endpoint"`
318318
Private bool `json:"private"`
319-
Description string `json:"description" binding:"MaxSize(255)"`
319+
Description string `json:"description" binding:"MaxSize(2048)"`
320320
Wiki bool `json:"wiki"`
321321
Milestones bool `json:"milestones"`
322322
Labels bool `json:"labels"`

services/forms/repo_form.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type CreateRepoForm struct {
3434
UID int64 `binding:"Required"`
3535
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
3636
Private bool
37-
Description string `binding:"MaxSize(255)"`
37+
Description string `binding:"MaxSize(2048)"`
3838
DefaultBranch string `binding:"GitRefName;MaxSize(100)"`
3939
AutoInit bool
4040
Gitignores string
@@ -76,7 +76,7 @@ type MigrateRepoForm struct {
7676
LFS bool `json:"lfs"`
7777
LFSEndpoint string `json:"lfs_endpoint"`
7878
Private bool `json:"private"`
79-
Description string `json:"description" binding:"MaxSize(255)"`
79+
Description string `json:"description" binding:"MaxSize(2048)"`
8080
Wiki bool `json:"wiki"`
8181
Milestones bool `json:"milestones"`
8282
Labels bool `json:"labels"`
@@ -116,8 +116,8 @@ func ParseRemoteAddr(remoteAddr, authUsername, authPassword string) (string, err
116116
// RepoSettingForm form for changing repository settings
117117
type RepoSettingForm struct {
118118
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
119-
Description string `binding:"MaxSize(255)"`
120-
Website string `binding:"ValidUrl;MaxSize(255)"`
119+
Description string `binding:"MaxSize(2048)"`
120+
Website string `binding:"ValidUrl;MaxSize(1024)"`
121121
Interval string
122122
MirrorAddress string
123123
MirrorUsername string

templates/repo/settings/options.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
{{end}}
4343
<div class="field {{if .Err_Description}}error{{end}}">
4444
<label for="description">{{$.locale.Tr "repo.repo_desc"}}</label>
45-
<textarea id="description" name="description" rows="2">{{.Repository.Description}}</textarea>
45+
<textarea id="description" name="description" rows="2" maxlength="2048">{{.Repository.Description}}</textarea>
4646
</div>
4747
<div class="field {{if .Err_Website}}error{{end}}">
4848
<label for="website">{{.locale.Tr "repo.settings.site"}}</label>
49-
<input id="website" name="website" type="url" value="{{.Repository.Website}}">
49+
<input id="website" name="website" type="url" maxlength="1024" value="{{.Repository.Website}}">
5050
</div>
5151

5252
<div class="field">

0 commit comments

Comments
 (0)