Page 1 of 1

Server Side Validation - $Error does not throw exception

Posted: Tue Dec 10, 2019 3:58 am
by Magical
Greetings,
Came across this issue with the generated php when server side validation is enabled. The $error variable seems to be evaluated after the mailto and so it never catches any error.

try {
if (!ValidateEmail($mailfrom))
{
$error .= "The specified email address (" . $mailfrom . ") is invalid!\n<br>";
throw new Exception($error);
}

if (empty($_POST['TextArea1']))
{
$error .= "Too many char\n<br>"; // NO THROW EXCEPTION HERE
}
if (strlen($_POST['TextArea1']) < 5)
{
$error .= "Too many char\n<br>";
}
if (strlen($_POST['TextArea1']) > 40)
{
$error .= "Too many char\n<br>"; //IF MORE THAN 40 CHARACTERS ENTERED THE CODE DOES NOTHING IT SENDS THE MAIL
}
$message .= $eol;
$message .= "IP Address : ";
$message .= $_SERVER['REMOTE_ADDR'];
$message .= $eol;
$message .= "Referer : ";
$message .= $_SERVER['SERVER_NAME'];
$message .= $_SERVER['PHP_SELF'];
$message .= $eol;

$body .= '--'.$boundary.'--'.$eol;
if ($mailto != '') THIS ONLY CHECKS IF THE MAILTO ADDRESS IS PRESENT IT SHOULD ALSO CHECK FOR IF $ERROR IS NOT EQUAL TO BLANK
{
mail($mailto, $subject, $body, $header); // MAIL IS SENT OVER HERE
}
header('Location: '.$success_url);
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>

Re: Server Side Validation - $Error does not throw exception

Posted: Tue Dec 10, 2019 7:44 am
by Pablo
Thanks for the information!
This issue has addressed in the latest build (12/10/2019)
http://www.wysiwygwebbuilder.com/download.html

Re: Server Side Validation - $Error does not throw exception

Posted: Tue Dec 10, 2019 7:35 pm
by Magical
Thanks, so after I download this fix, do I just reopen each project and redeploy?

Re: Server Side Validation - $Error does not throw exception

Posted: Tue Dec 10, 2019 7:51 pm
by Magical
Tested it, works fine now! Thanks