... | ... |
@@ -34,6 +34,9 @@ |
34 | 34 |
if (!(defined $to_project && length $to_project)) { |
35 | 35 |
$validation->add_failed('to-project' => 'Repository name is empty.'); |
36 | 36 |
} |
37 |
+ elsif (length $to_project > 300) { |
|
38 |
+ $validation->add_failed('to-project' => 'Repository name is too long.'); |
|
39 |
+ } |
|
37 | 40 |
elsif (!$vc->check($to_project, 'project_name')) { |
38 | 41 |
$validation->add_failed('to-project' => 'Repository name contains invalid charactor.'); |
39 | 42 |
} |
... | ... |
@@ -59,18 +62,32 @@ |
59 | 62 |
|
60 | 63 |
# Change description |
61 | 64 |
elsif ($op eq 'change-description') { |
65 |
+ |
|
66 |
+ # Parameters |
|
62 | 67 |
my $description = param('description'); |
63 | 68 |
$description = '' unless defined $description; |
69 |
+ |
|
70 |
+ # Validator |
|
71 |
+ my $vc = app->vc; |
|
64 | 72 |
|
65 |
- eval { $git->description(app->rep_info($user_id, $project_id), $description) }; |
|
66 |
- if (my $e = $@) { |
|
67 |
- app->log->error("/$user_id/$project_id/settings?op=description: $e"); |
|
68 |
- $errors = ['Internal Error']; |
|
73 |
+ # Validation result |
|
74 |
+ my $validation = $vc->validation; |
|
75 |
+ |
|
76 |
+ if (length $description > 300) { |
|
77 |
+ $validation->add_failed(description => 'description is too long'); |
|
69 | 78 |
} |
70 |
- else { |
|
71 |
- flash(message => 'Description is saved.'); |
|
72 |
- $self->redirect_to('current'); |
|
73 |
- return; |
|
79 |
+ |
|
80 |
+ if ($validation->is_valid) { |
|
81 |
+ eval { $git->description(app->rep_info($user_id, $project_id), $description) }; |
|
82 |
+ if (my $e = $@) { |
|
83 |
+ app->log->error("/$user_id/$project_id/settings?op=description: $e"); |
|
84 |
+ $errors = ['Internal Error']; |
|
85 |
+ } |
|
86 |
+ else { |
|
87 |
+ flash(message => 'Description is saved.'); |
|
88 |
+ $self->redirect_to('current'); |
|
89 |
+ return; |
|
90 |
+ } |
|
74 | 91 |
} |
75 | 92 |
} |
76 | 93 |
|
... | ... |
@@ -82,16 +99,39 @@ |
82 | 99 |
my $private = param('private'); |
83 | 100 |
my $ignore_space_change = param('ignore_space_change'); |
84 | 101 |
my $guess_encoding = param('guess_encoding'); |
102 |
+ |
|
103 |
+ # Validator |
|
104 |
+ my $vc = app->vc; |
|
105 |
+ |
|
106 |
+ # Validation result |
|
107 |
+ my $validation = $vc->validation; |
|
108 |
+ |
|
109 |
+ # Check default branch |
|
110 |
+ if (length $default_branch > 300) { |
|
111 |
+ $validation->add_failed('default-branch' => 'default branch is too long'); |
|
112 |
+ } |
|
113 |
+ |
|
114 |
+ # Check private |
|
115 |
+ $private = $private ? 1 : 0; |
|
116 |
+ |
|
117 |
+ # Check ignore space change |
|
118 |
+ $ignore_space_change = $ignore_space_change ? 1 : 0; |
|
119 |
+ |
|
120 |
+ # Check guess encoding |
|
121 |
+ $guess_encoding //= ''; |
|
122 |
+ if (length $guess_encoding > 300) { |
|
123 |
+ $validation->add_failed(guess_encoding => 'guess_encoding is too long'); |
|
124 |
+ } |
|
85 | 125 |
|
86 | 126 |
my $params = {}; |
87 | 127 |
if (defined $default_branch) { |
88 | 128 |
$params->{default_branch} = $default_branch; |
89 | 129 |
} |
90 | 130 |
if (defined $private) { |
91 |
- $params->{private} = $private ? 1 : 0; |
|
131 |
+ $params->{private} = $private; |
|
92 | 132 |
}; |
93 | 133 |
if (defined $ignore_space_change) { |
94 |
- $params->{ignore_space_change} = $ignore_space_change ? 1 : 0; |
|
134 |
+ $params->{ignore_space_change} = $ignore_space_change; |
|
95 | 135 |
} |
96 | 136 |
if (defined $guess_encoding) { |
97 | 137 |
$params->{guess_encoding} = $guess_encoding; |