Skip to content

Commit

Permalink
Avoid sending empty email when invoking the feedback form. Fixes #1139
Browse files Browse the repository at this point in the history
  • Loading branch information
osma committed Apr 7, 2021
1 parent 62c8611 commit 8f16c65
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,21 @@ public function invokeFeedbackForm($request)
$vocab = $request->getVocab();

$feedbackSent = false;
$feedbackMsg = null;
if ($request->getQueryParamPOST('message')) {
$feedbackSent = true;
$feedbackMsg = $request->getQueryParamPOST('message');
}
$feedbackName = $request->getQueryParamPOST('name');
$feedbackEmail = $request->getQueryParamPOST('email');
$msgSubject = $request->getQueryParamPOST('msgsubject');
$feedbackVocab = $request->getQueryParamPOST('vocab');
$feedbackVocabEmail = ($feedbackVocab !== null && $feedbackVocab !== '') ?
$this->model->getVocabulary($feedbackVocab)->getConfig()->getFeedbackRecipient() : null;
// if the hidden field has been set a value we have found a spam bot
// and we do not actually send the message.
if ($this->honeypot->validateHoneypot($request->getQueryParamPOST('item-description')) &&
$this->honeypot->validateHoneytime($request->getQueryParamPOST('user-captcha'), $this->model->getConfig()->getHoneypotTime())) {
$this->sendFeedback($request, $feedbackMsg, $msgSubject, $feedbackName, $feedbackEmail, $feedbackVocab, $feedbackVocabEmail);
$feedbackName = $request->getQueryParamPOST('name');
$feedbackEmail = $request->getQueryParamPOST('email');
$msgSubject = $request->getQueryParamPOST('msgsubject');
$feedbackVocab = $request->getQueryParamPOST('vocab');
$feedbackVocabEmail = ($feedbackVocab !== null && $feedbackVocab !== '') ?
$this->model->getVocabulary($feedbackVocab)->getConfig()->getFeedbackRecipient() : null;
// if the hidden field has been set a value we have found a spam bot
// and we do not actually send the message.
if ($this->honeypot->validateHoneypot($request->getQueryParamPOST('item-description')) &&
$this->honeypot->validateHoneytime($request->getQueryParamPOST('user-captcha'), $this->model->getConfig()->getHoneypotTime())) {
$this->sendFeedback($request, $feedbackMsg, $msgSubject, $feedbackName, $feedbackEmail, $feedbackVocab, $feedbackVocabEmail);
}
}
echo $template->render(
array(
Expand Down

0 comments on commit 8f16c65

Please sign in to comment.