diff --git a/composer.json b/composer.json index 4e47010..744b677 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,9 @@ { "config": { - "version": "3.10.2" + "version": "3.10.3", + "allow-plugins": { + "simplesamlphp/composer-module-installer": true + } }, "repositories": { "spid-sp-access-button": { diff --git a/setup/Setup.php b/setup/Setup.php index 20956f8..9fec4dd 100644 --- a/setup/Setup.php +++ b/setup/Setup.php @@ -103,12 +103,21 @@ public static function setup(Event $event) { } if (!isset($config['serviceName'])) { - echo "Please insert name for service endpoint (" . - $colors->getColoredString($_serviceName, "green") . "): "; - $config['serviceName'] = str_replace("'", "\'", readline()); - if ($config['serviceName'] == null || $config['serviceName'] == "") { - $config['serviceName'] = $_serviceName; - } + do { + echo "Please insert name for service endpoint (" . + $colors->getColoredString($_serviceName, "green") . "): "; + $serviceName = readline(); + if ($serviceName == null || $serviceName == "") { + $serviceName = $_serviceName; + break; + } + $is_valid = preg_match("/^\w{1}[-\w]*$/i", $serviceName); + if (!$is_valid) + echo "Value '{$serviceName}' not allowed\n"; + + } while(!$is_valid); + $config['serviceName'] = $serviceName; + } if (!isset($config['entityID'])) { @@ -1310,12 +1319,20 @@ public static function remove() { if (!empty($config['serviceName'])) { $serviceName = $config['serviceName']; } else { - echo "Please insert name for service endpoint (" . - $colors->getColoredString($_serviceName, "green") . "): "; - $serviceName = readline(); - if ($serviceName == null || $serviceName == "") { - $serviceName = $_serviceName; - } + do { + echo "Please insert name for service endpoint (" . + $colors->getColoredString($_serviceName, "green") . "): "; + $serviceName = readline(); + if ($serviceName == null || $serviceName == "") { + $serviceName = $_serviceName; + break; + } + $is_valid = preg_match("/^\w{1}[-\w]*$/i", $serviceName); + if (!$is_valid) + echo "Value '{$serviceName}' not allowed\n"; + + } while(!$is_valid); + } if (file_exists("{$installDir}/vendor/simplesamlphp/simplesamlphp/log/simplesamlphp.log")) {