Skip to content
Snippets Groups Projects
Commit 17d05050 authored by Olivier PEREZ's avatar Olivier PEREZ
Browse files

UrlNaming - Allow new id format when loading a poll

parent 1efd7b9a
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ class PollService {
* @return \stdClass|null The found poll, or null
*/
function findById($poll_id) {
if (preg_match('/^[\w\d]{16}$/i', $poll_id)) {
if (preg_match(POLL_REGEX, $poll_id)) {
return $this->pollRepository->findById($poll_id);
}
......@@ -57,7 +57,7 @@ class PollService {
}
public function findByAdminId($admin_poll_id) {
if (preg_match('/^[\w\d]{24}$/i', $admin_poll_id)) {
if (preg_match(ADMIN_POLL_REGEX, $admin_poll_id)) {
return $this->pollRepository->findByAdminId($admin_poll_id);
}
......
......@@ -22,6 +22,7 @@ const VERSION = '0.9';
// Regex
const POLL_REGEX = '/^[a-z0-9-]*$/i';
const ADMIN_POLL_REGEX = '/^[\w\d]{24}$/i';
const CHOICE_REGEX = '/^[012]$/';
const BOOLEAN_REGEX = '/^(on|off|true|false|1|0)$/i';
const BOOLEAN_TRUE_REGEX = '/^(on|true|1)$/i';
......
......@@ -58,9 +58,7 @@ $securityService = new SecurityService();
if (!empty($_GET['poll'])) {
$poll_id = filter_input(INPUT_GET, 'poll', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
if (strlen($poll_id) === 16) {
$poll = $pollService->findById($poll_id);
}
$poll = $pollService->findById($poll_id);
}
if (!$poll) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment