Basic input validation
This commit is contained in:
parent
48de91f31b
commit
705a136690
15
PostText.pl
15
PostText.pl
|
@ -44,12 +44,21 @@ get '/view', sub ($c) {
|
||||||
|
|
||||||
# Post
|
# Post
|
||||||
any [qw{GET POST}], '/post', sub ($c) {
|
any [qw{GET POST}], '/post', sub ($c) {
|
||||||
my $thread_author = $c->param('name' );
|
my $v;
|
||||||
|
|
||||||
|
$v = $c->validation() if $c->req->method eq 'POST';
|
||||||
|
|
||||||
|
if ($v && $v->has_data) {
|
||||||
|
my $thread_author = $c->param('name' ) || 'Anonymous';
|
||||||
my $thread_title = $c->param('title');
|
my $thread_title = $c->param('title');
|
||||||
my $thread_body = $c->param('post' );
|
my $thread_body = $c->param('post' );
|
||||||
|
|
||||||
if ($thread_author && $thread_title && $thread_body) {
|
$v->required('name' )->size(1, 63 );
|
||||||
$c->thread->create_thread($thread_author, $thread_title, $thread_body);
|
$v->required('title')->size(1, 127 );
|
||||||
|
$v->required('post' )->size(2, 4000);
|
||||||
|
|
||||||
|
$c->thread->create_thread($thread_author, $thread_title, $thread_body)
|
||||||
|
unless $v->has_error();
|
||||||
|
|
||||||
return $c->redirect_to('view');
|
return $c->redirect_to('view');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user