This commit is contained in:
Miraty 2022-06-28 22:09:54 +02:00
commit a81016a73a
3 changed files with 6 additions and 6 deletions

View file

@ -1,7 +1,7 @@
<?php
define("USERNAME_REGEX", "^[a-z]{4,32}$");
define("PASSWORD_REGEX", "^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8,1024}|.{10,1024}$");
define("USERNAME_REGEX", "^[\p{L}\p{N}_-]{1,64}$");
define("PASSWORD_REGEX", "^(?=.*[\p{Ll}])(?=.*[\p{Lu}])(?=.*[\p{N}]).{8,1024}|.{10,1024}$");
define("PLACEHOLDER_USERNAME", "lain");
define("PLACEHOLDER_PASSWORD", "••••••••••••••••••••••••");
@ -15,12 +15,12 @@ define("OPTIONS_PASSWORD", array(
));
function checkPasswordFormat($password) {
if (preg_match("/" . PASSWORD_REGEX . "/", $password) !== 1)
if (preg_match("/" . PASSWORD_REGEX . "/u", $password) !== 1)
userError("Password malformed.");
}
function checkUsernameFormat($username) {
if (preg_match("/" . USERNAME_REGEX . "/", $username) !== 1)
if (preg_match("/" . USERNAME_REGEX . "/u", $username) !== 1)
userError("Username malformed.");
}

View file

@ -10,7 +10,7 @@ function listFsDirs($username) {
$absoluteDirs = glob(CONF['ht']['ht_path'] . "/" . $username . "/*/", GLOB_ONLYDIR);
$dirs = [];
foreach ($absoluteDirs as $absoluteDir)
if (preg_match("/^[a-z0-9-]{1,32}$/", basename($absoluteDir)))
if (preg_match("/^[\p{L}\p{N}_-]+$/u", basename($absoluteDir)))
array_push($dirs, basename($absoluteDir));
return $dirs;
}

View file

@ -8,7 +8,7 @@
<summary><label for="username">Identifiant</label></summary>
Uniquement composé de lettres minuscules.
</details>
<input id="username" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>"><br>
<input id="username" maxlength="32" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>"><br>
<details>
<summary><label for="password">Clé de passe</label></summary>