Filter URLs out of message body
This commit is contained in:
parent
26aa2ba19f
commit
baca0cd515
|
@ -50,5 +50,4 @@ Add the `-v` option for more verbose output
|
|||
## TODOs
|
||||
|
||||
1. Input validation
|
||||
1. Filter URLs out of message body
|
||||
1. Set date in the DB rather than the model
|
||||
|
|
1
cpanfile
1
cpanfile
|
@ -5,3 +5,4 @@ requires 'Mojolicious::Lite';
|
|||
requires 'Mojo::Pg';
|
||||
requires 'Mojolicious::Plugin::TagHelpers::Pagination';
|
||||
requires 'Mojolicious::Plugin::AssetPack';
|
||||
requires 'Regexp::Common::URI';
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
use Mojolicious::Lite -signatures;
|
||||
use Mojo::Pg;
|
||||
use List::Util qw{shuffle};
|
||||
use Regexp::Common qw{URI};
|
||||
use Data::Dumper; # Uncomment for debugging
|
||||
|
||||
# Load the model
|
||||
|
@ -69,6 +70,10 @@ any [qw{GET POST}], '/sign' => sub ($c) {
|
|||
my $message = $c->param('message');
|
||||
my $spam = $c->param('answer') ? 0 : 1;
|
||||
|
||||
# No URLs in message body since they have their own field
|
||||
$spam =
|
||||
$message =~ /$RE{URI}{HTTP}{-scheme => qr<https?>}/ ? 1 : 0;
|
||||
|
||||
if ($message) {
|
||||
$c->message->create_post($name, $message, $url, $spam);
|
||||
$c->redirect_to('index');
|
||||
|
|
Loading…
Reference in a new issue