Skip to content
Snippets Groups Projects
Commit d8d7639c authored by Demian Katz's avatar Demian Katz
Browse files

Added server-side validation for feedback module; corrected typo.

parent ec071a50
No related merge requests found
...@@ -45,9 +45,17 @@ class FeedbackController extends AbstractBase ...@@ -45,9 +45,17 @@ class FeedbackController extends AbstractBase
*/ */
public function emailAction() public function emailAction()
{ {
$name = $this->params()->fromPost('name', 'No Name Given'); $name = $this->params()->fromPost('name');
$users_email = $this->params()->fromPost('email', 'user@noemail.com'); $users_email = $this->params()->fromPost('email');
$comments = $this->params()->fromPost('comments', ''); $comments = $this->params()->fromPost('comments');
if (empty($name) || empty($users_email) || empty($comments)) {
throw new \Exception('Missing data.');
}
$validator = new \Zend\Validator\EmailAddress();
if (!$validator->isValid($users_email)) {
throw \Exception('Email address is invalid');
}
// These settings are set in the feedback settion of your config.ini // These settings are set in the feedback settion of your config.ini
$config = $this->getServiceLocator()->get('VuFind\Config')->get('config'); $config = $this->getServiceLocator()->get('VuFind\Config')->get('config');
...@@ -57,7 +65,7 @@ class FeedbackController extends AbstractBase ...@@ -57,7 +65,7 @@ class FeedbackController extends AbstractBase
$recipient_name = isset($feedback->recipient_name) $recipient_name = isset($feedback->recipient_name)
? $feedback->recipient_name : 'Your Library'; ? $feedback->recipient_name : 'Your Library';
$email_subject = isset($feedback->email_subject) $email_subject = isset($feedback->email_subject)
? $feedback->email_subject : 'Vufind Feedback'; ? $feedback->email_subject : 'VuFind Feedback';
$sender_email = isset($feedback->sender_email) $sender_email = isset($feedback->sender_email)
? $feedback->sender_email : 'noreply@vufind.org'; ? $feedback->sender_email : 'noreply@vufind.org';
$sender_name = isset($feedback->sender_name) $sender_name = isset($feedback->sender_name)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment