MasterPasswordInitForm: Check whether password equals username
authorTim Düsterhus <timwolla@arcor.de>
Sun, 15 Jan 2012 14:15:52 +0000 (15:15 +0100)
committerTim Düsterhus <timwolla@arcor.de>
Sun, 15 Jan 2012 14:16:43 +0000 (15:16 +0100)
wcfsetup/install/files/lib/acp/form/MasterPasswordInitForm.class.php

index 9f1445420b202bf556372d01b2e325568264a8a7..04d9186fe6aa6b3357d2faa8c21b2fcce4fb30d4 100755 (executable)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\acp\form;
+use wcf\system\Regex;
 use wcf\system\WCF;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\UserInputException;
@@ -64,19 +65,24 @@ class MasterPasswordInitForm extends MasterPasswordForm {
                        throw new UserInputException('masterPassword', 'notSecure');
                }
                // digits
-               if (!preg_match('![0-9]+!', $this->masterPassword)) {
+               if (!Regex::compile('\d')->match($this->masterPassword)) {
                        throw new UserInputException('masterPassword', 'notSecure');
                }
                // latin characters (lower-case)
-               if (!preg_match('![a-z]+!', $this->masterPassword)) {
+               if (!Regex::compile('[a-z]')->match($this->masterPassword)) {
                        throw new UserInputException('masterPassword', 'notSecure');
                }
                // latin characters (upper-case)
-               if (!preg_match('![A-Z]+!', $this->masterPassword)) {
+               if (!Regex::compile('[A-Z]')->match($this->masterPassword)) {
                        throw new UserInputException('masterPassword', 'notSecure');
                }
                // special characters
-               if (!preg_match('![^A-Za-z0-9]+!', $this->masterPassword)) {
+               if (!Regex::compile('[^0-9a-zA-Z]')->match($this->masterPassword)) {
+                       throw new UserInputException('masterPassword', 'notSecure');
+               }
+               
+               // password equals username
+               if ($this->masterPassword == WCF::getUser()->username) {
                        throw new UserInputException('masterPassword', 'notSecure');
                }