From 12859a501e7f7b03ad7738d4be15ee24b5ddc1cf Mon Sep 17 00:00:00 2001 From: Jacob Andersen Date: Wed, 4 Apr 2018 19:19:51 -0700 Subject: [PATCH 1/2] Make sure we check if the variables are set. --- shorty.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/shorty.php b/shorty.php index 16546bf..c760e91 100644 --- a/shorty.php +++ b/shorty.php @@ -311,9 +311,17 @@ public function allow($ip) { * Starts the program. */ public function run() { - $q = str_replace('/', '', $_GET['q']); - $url = urldecode($_GET['url']); - $format = strtolower($_GET['format']); + $q = str_replace('/', '', $_GET['q']); + + $url = ''; + if (isset($_GET['url'])) { + $url = urldecode($_GET['url']); + } + + $format = ''; + if (isset($_GET['format'])) { + $format = strtolower($_GET['format']); + } // If adding a new URL if (!empty($url)) { From 235409b32cad1432a252c91b0687c2b21e35a0db Mon Sep 17 00:00:00 2001 From: Jacob Andersen Date: Wed, 4 Apr 2018 19:22:17 -0700 Subject: [PATCH 2/2] Trigger 404 on homepage --- shorty.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shorty.php b/shorty.php index c760e91..59b24b6 100644 --- a/shorty.php +++ b/shorty.php @@ -311,7 +311,11 @@ public function allow($ip) { * Starts the program. */ public function run() { - $q = str_replace('/', '', $_GET['q']); + $q = str_replace('/', '', $_GET['q']); + if (empty($q)) { + $this->not_found(); + return; + } $url = ''; if (isset($_GET['url'])) {