Filter URLs out of message body

This commit is contained in:
swagg boi 2022-01-02 02:01:45 -05:00
parent 26aa2ba19f
commit baca0cd515
3 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -5,3 +5,4 @@ requires 'Mojolicious::Lite';
requires 'Mojo::Pg';
requires 'Mojolicious::Plugin::TagHelpers::Pagination';
requires 'Mojolicious::Plugin::AssetPack';
requires 'Regexp::Common::URI';

View file

@ -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');