Skip to content

Commit

Permalink
Add assertion to prevent illegal characters in tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Nov 13, 2024
1 parent 6e37a32 commit 2c9dfdd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/PowerIdPDisco.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleSAML\Module\discopower;

use Exception;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Auth;
use SimpleSAML\Configuration;
use SimpleSAML\Logger;
Expand Down Expand Up @@ -337,6 +338,13 @@ public function handleRequest(): void
$t->data['rememberenabled'] = $this->config->getOptionalBoolean('idpdisco.enableremember', false);
$t->data['rememberchecked'] = $this->config->getOptionalBoolean('idpdisco.rememberchecked', false);
foreach (array_keys($idpList) as $tab) {
Assert::regex(
$tab,
'/^[a-z_][a-z0-9_-]+$/',
'Tags can contain alphanumeric characters, hyphens and underscores.'
. ' They must start with a A-Z or an underscore.',
);

$translatableTag = "{discopower:tabs:$tab}";
if ($translator::translateSingularGettext($translatableTag) === $translatableTag) {
$t->data['tabNames'][$tab] = $translator::noop($tab);
Expand Down

0 comments on commit 2c9dfdd

Please sign in to comment.