@@ -312,10 +312,8 @@ public static function createAccount(string $username, string $password, string
312312 if ($ amount_of_accounts >= Settings::getMaxAccounts ()) return Display::json (15 );
313313 }
314314
315- $ sub_email = filter_var ($ email , FILTER_SANITIZE_EMAIL );
316-
317315 if (!preg_match ("/^[a-z0-9._]{6,30}$/i " , $ username )) return Display::json (12 );
318- if (!filter_var ( $ sub_email , FILTER_VALIDATE_EMAIL ) ) return Display::json (6 );
316+ if (!preg_match ( " /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,}$/i " , $ email ) || strlen ( $ email ) > 200 ) return Display::json (6 );
319317 if (!preg_match ("/^[a-z0-9]{128}$/i " , $ password )) return Display::json (5 );
320318
321319 $ username = strtolower ($ username );
@@ -923,14 +921,15 @@ public static function removeYubiKey(string $username, string $token, string $id
923921
924922 public static function forgotUsername (string $ email ) : string {
925923 if (!Settings::getMail ()) return Display::json (28 );
926- $ sub_email = filter_var ($ email , FILTER_SANITIZE_EMAIL );
927- if (!filter_var ($ sub_email , FILTER_VALIDATE_EMAIL )) return Display::json (6 );
924+ if (!preg_match ("/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]{2,}$/i " , $ email ) || strlen ($ email ) > 200 ) return Display::json (6 );
925+
926+ $ email = strtolower ($ email );
928927
929928 try {
930929 $ conn = Settings::createConnection ();
931930
932931 $ stmt = $ conn ->prepare ('SELECT username FROM users WHERE email = :email ' );
933- $ stmt ->bindParam (':email ' , $ sub_email , PDO ::PARAM_STR );
932+ $ stmt ->bindParam (':email ' , $ email , PDO ::PARAM_STR );
934933 $ stmt ->execute ();
935934
936935 $ rows = $ stmt ->fetchAll (PDO ::FETCH_ASSOC );
0 commit comments