Skip to content

Commit

Permalink
Use a PCRE to identify valid entity IDs
Browse files Browse the repository at this point in the history
Toward #90 and #72.
  • Loading branch information
waldoj committed Sep 16, 2019
1 parent 7fce9ce commit 5b73449
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion business.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ function get_content($url)

}

/*
* Define the PCRE to match all entity IDs
*/
$entity_id_pcre = '/(F|S|T|L|M|[0-9])([0-9]{6})/';

/*
* If no business ID has been passed in the URL
*/
Expand All @@ -37,7 +42,7 @@ function get_content($url)
/*
* If the business ID has an invalid format
*/
elseif ( strlen($_GET['id']) < 7 || strlen($_GET['id']) > 9 )
elseif ( preg_match($entity_id_pcre, $_GET['id'] == 0) )
{
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
exit();
Expand Down

0 comments on commit 5b73449

Please sign in to comment.