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
|
## TODOs
|
||||||
|
|
||||||
1. Input validation
|
1. Input validation
|
||||||
1. Filter URLs out of message body
|
|
||||||
1. Set date in the DB rather than the model
|
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 'Mojo::Pg';
|
||||||
requires 'Mojolicious::Plugin::TagHelpers::Pagination';
|
requires 'Mojolicious::Plugin::TagHelpers::Pagination';
|
||||||
requires 'Mojolicious::Plugin::AssetPack';
|
requires 'Mojolicious::Plugin::AssetPack';
|
||||||
|
requires 'Regexp::Common::URI';
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
use Mojolicious::Lite -signatures;
|
use Mojolicious::Lite -signatures;
|
||||||
use Mojo::Pg;
|
use Mojo::Pg;
|
||||||
use List::Util qw{shuffle};
|
use List::Util qw{shuffle};
|
||||||
|
use Regexp::Common qw{URI};
|
||||||
use Data::Dumper; # Uncomment for debugging
|
use Data::Dumper; # Uncomment for debugging
|
||||||
|
|
||||||
# Load the model
|
# Load the model
|
||||||
|
@ -69,6 +70,10 @@ any [qw{GET POST}], '/sign' => sub ($c) {
|
||||||
my $message = $c->param('message');
|
my $message = $c->param('message');
|
||||||
my $spam = $c->param('answer') ? 0 : 1;
|
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) {
|
if ($message) {
|
||||||
$c->message->create_post($name, $message, $url, $spam);
|
$c->message->create_post($name, $message, $url, $spam);
|
||||||
$c->redirect_to('index');
|
$c->redirect_to('index');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user