fixed I18n->translate(), username validation

This commit is contained in:
crispycat 2024-02-02 23:06:01 -05:00
parent 798e274503
commit 812a84e9f8
2 changed files with 3 additions and 1 deletions

View File

@ -396,6 +396,8 @@
if (!Config::ENABLE_USER_REGISTRATION || !$registration_enabled) if (!Config::ENABLE_USER_REGISTRATION || !$registration_enabled)
return static::ERR_REGISTER_DISABLED; return static::ERR_REGISTER_DISABLED;
$username = preg_replace("/\\W/", "_", strtolower($username));
// Check that user doesn't exist // Check that user doesn't exist
$user = $this->app->assets->getBySlug( $user = $this->app->assets->getBySlug(
"\\Crispage\\Assets\\User", $username "\\Crispage\\Assets\\User", $username

View File

@ -124,7 +124,7 @@
$num = preg_match_all(self::TS_REGEX, $str, $matches, PREG_OFFSET_CAPTURE); $num = preg_match_all(self::TS_REGEX, $str, $matches, PREG_OFFSET_CAPTURE);
// If no keys, return the input // If no keys, return the input
if (!$num) return $str; if (!$num) return (empty($vars)) ? $str : sprintf($str, ...$vars);
// Initialize position and output variables // Initialize position and output variables
$pos = 0; $pos = 0;