widget/contact: accept non-word characters in sender email addresses
[minimedit.git] / widget / contact.php
index b50537517d7b68952f50922a53c244b7763e8e91..6e04005226abade032281e95fb36f750dfe8f521 100644 (file)
@@ -4,6 +4,10 @@ if ($_POST) {
        global $User;
        if ($User) {
                $_REQUEST['login'] = $User->login;
+               $_REQUEST['email'] = $_REQUEST['email'] ?: $User->email;
+       }
+       else {
+               unset($_REQUEST['login']);
        }
        $error = mailform($_REQUEST);
        if (!empty($error)) {
@@ -46,7 +50,7 @@ switch ($source) {
        }
 }
 
-       $reply = preg_match('/\A\w+@\w+\.[a-z]+\z/', @$input['email'])
+       $reply = preg_match('/\A[^\s\'@]{1,64}@[.a-zA-Z0-9-]{4,63}\z/', @$input['email'])
                ? $input['email'] : "noreply@$domain";
        $header = "From: $reply";