Skip to content

Commit

Permalink
fix: type coercion in TU/e-username year check
Browse files Browse the repository at this point in the history
Co-Authored-By: Rink <rinkp@users.noreply.github.com>
  • Loading branch information
tomudding and rinkp committed Sep 2, 2024
1 parent bf75a25 commit 0c98247
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions module/Database/src/Form/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Throwable;

use function date;
use function intval;
use function preg_match;
use function str_ends_with;
use function substr;
Expand Down Expand Up @@ -432,8 +433,8 @@ private function isNewTueUsernameValid(string $value): bool
return true;
}

$year = substr($value, 0, 4);
$currentYear = date('Y');
$year = intval(substr($value, 0, 4));
$currentYear = intval(date('Y'));

// Check if the year is within the valid range, the assumption being that you can never have a number
// starting with a year that is higher than the current year.
Expand Down
5 changes: 3 additions & 2 deletions module/Database/src/Form/MemberEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Throwable;

use function date;
use function intval;
use function preg_match;
use function substr;

Expand Down Expand Up @@ -251,8 +252,8 @@ private function isNewTueUsernameValid(string $value): bool
return true;
}

$year = substr($value, 0, 4);
$currentYear = date('Y');
$year = intval(substr($value, 0, 4));
$currentYear = intval(date('Y'));

// Check if the year is within the valid range, the assumption being that you can never have a number
// starting with a year that is higher than the current year.
Expand Down

0 comments on commit 0c98247

Please sign in to comment.