From 74520b1b65b7dd7fded658033d19db55fa77f319 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Wed, 8 Aug 2018 22:46:07 -0400 Subject: more type checking --- Bugzilla/Quantum/SES.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Bugzilla/Quantum/SES.pm b/Bugzilla/Quantum/SES.pm index e447b036a..03916075d 100644 --- a/Bugzilla/Quantum/SES.pm +++ b/Bugzilla/Quantum/SES.pm @@ -31,7 +31,7 @@ sub main { } catch { FATAL("Error in SES Handler: ", $_); - die $_; + $self->_respond( 400 => 'Bad Request' ); }; } @@ -67,7 +67,8 @@ sub _main { } sub _confirm_subscription { - my ($self, $message) = @_; + state $check = compile($Invocant, Dict[SubscribeURL => Str, slurpy Any]); + my ($self, $message) = $check->(@_); my $subscribe_url = $message->{SubscribeURL}; if ( !$subscribe_url ) { @@ -223,13 +224,9 @@ sub _respond { } sub _decode_json_wrapper { - my ($self, $json) = @_; + state $check = compile($Invocant, Str); + my ($self, $json) = $check->(@_); my $result; - if ( !defined $json ) { - WARN( 'Missing JSON from ' . $self->tx->remote_address ); - $self->_respond( 400 => 'Bad Request' ); - return undef; - } my $ok = try { $result = decode_json($json); } -- cgit v1.2.3-24-g4f1b