Properly validating sender email address
authorAlexander Ebert <ebert@woltlab.com>
Sun, 2 Oct 2016 11:21:55 +0000 (13:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 2 Oct 2016 11:22:02 +0000 (13:22 +0200)
wcfsetup/install/files/acp/templates/userMail.tpl
wcfsetup/install/files/lib/acp/form/UserMailForm.class.php

index f8574b68555076ae09af73425e6a8429278f85b1..98a6e1c3cfdfca95b90e9c93c640e4cccf143ac0 100644 (file)
                                        <small class="innerError">
                                                {if $errorType == 'empty'}
                                                        {lang}wcf.global.form.error.empty{/lang}
+                                               {elseif $errorType == 'invalid'}
+                                                       {lang}wcf.user.email.error.invalid{/lang}
                                                {else}
                                                        {lang}wcf.acp.user.sendMail.subject.from.{@$errorType}{/lang}
                                                {/if}
index 642c70f9ca96337bbb73daa57b2ca483d5e59f7b..41c4ff214faabb73daf7b4ed7eb67af9c6f7ad01 100755 (executable)
@@ -4,6 +4,7 @@ use wcf\data\user\group\UserGroup;
 use wcf\data\user\UserList;
 use wcf\form\AbstractForm;
 use wcf\system\clipboard\ClipboardHandler;
+use wcf\system\email\EmailGrammar;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\SystemException;
 use wcf\system\exception\UserInputException;
@@ -120,6 +121,9 @@ class UserMailForm extends AbstractForm {
                if (empty($this->from)) {
                        throw new UserInputException('from');
                }
+               else if (!preg_match('(^'.EmailGrammar::getGrammar('addr-spec').'$)', $this->from)) {
+                       throw new UserInputException('from', 'invalid');
+               }
        }
        
        /**