From 4a7ffab92713bb88438cef1d0a6fc91f1792724c Mon Sep 17 00:00:00 2001 From: r4sas Date: Fri, 26 Aug 2022 17:29:19 +0000 Subject: [PATCH] fix domain validator, search with "alive" ("a") option in GET --- lib/checker.php | 1 - lib/utils.php | 8 ++++---- views/search.php | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/checker.php b/lib/checker.php index c216888..f7623b8 100644 --- a/lib/checker.php +++ b/lib/checker.php @@ -48,4 +48,3 @@ class Checker implements Task { return $ts; } } - diff --git a/lib/utils.php b/lib/utils.php index d775ba6..3b2de0f 100644 --- a/lib/utils.php +++ b/lib/utils.php @@ -168,12 +168,12 @@ class Utils { return false; } - if(filter_var($data, FILTER_VALIDATE_DOMAIN) !== false && preg_match('/\.i2p$/', $data)) { - return true; + if(filter_var($data, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false || !preg_match('/\.i2p$/', $data)) { + $result = "Domain is not valid. The label must be less than 63 characters long, contain only alphanumerics or hyphens and end with .i2p."; + return false; } - $result = "Domain is not valid. Check if you domain label is lesser than 63 chars and it ends with .i2p."; - return false; + return true; } public static function verifyHostRecord(string $data, &$output): bool { diff --git a/views/search.php b/views/search.php index 0bb9a8b..4a68839 100644 --- a/views/search.php +++ b/views/search.php @@ -25,7 +25,7 @@ if (isset($query) && strlen($query) > 67 || isset($_POST["q"]) && strlen($_POST[ $q = htmlspecialchars($_POST["q"]); } -if (isset($_POST["a"])) +if (isset($_POST["a"]) || isset($_GET["a"])) $a = true; if (isset($_POST["all"]) || isset($_GET["all"]))