From 0911066c20fa2d7df845a3c5f58ea37053ff45f2 Mon Sep 17 00:00:00 2001 From: peteyboy Date: Thu, 17 Feb 2022 02:24:40 +0000 Subject: [PATCH] -remove copypasta die error, it doesn't work here -if user blanks the textarea, put the default text back, thus handling bug where form 500s if the world-result is blank. Just in case, if the wordle-result is blank, fill it with the default text --- wordle-life.cgi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wordle-life.cgi b/wordle-life.cgi index 8fa0b82..27fe919 100755 --- a/wordle-life.cgi +++ b/wordle-life.cgi @@ -49,8 +49,11 @@ use Readonly; #$wordle = ""; } elsif ($method eq 'POST') { #textarea name, pull the value from POST and reload into textarea - $wordle = $cgi->body_param('wordle-result'); - + if ( grep( /^wordle-result$/, $cgi->body_param_names) ) { #if no param exists, go down same path with default text as in GET case + $wordle = chomp($cgi->body_param('wordle-result')); + }else{ + $wordle = $defaulttext; + } #if input textarea not changed from default text, do nothing unless ($wordle =~ /\Q$defaulttext\E/) { #[Cc] /){ #cheat, if they put in something that looks like an RLE, pass output through @@ -67,8 +70,6 @@ use Readonly; exit; } - die "Invalid wordle parameter" unless length $wordle; - #Load template from DATA section and output my $mt = Mojo::Template->new(auto_escape => 1, vars => 1); my $template = data_section __PACKAGE__, 'index.html.ep'; @@ -83,7 +84,7 @@ use Readonly; sub generate_rle { my $headline = ""; - my $rleline; + my $rleline = ""; my $rowcount; my $myline;