From f478728ab95e4d055ad66631f587cd1774185a48 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Fri, 4 Sep 2020 01:19:00 +0200 Subject: [PATCH] Improve sanitizing functions for mail and url --- MD_STD_IN.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MD_STD_IN.php b/MD_STD_IN.php index 4a648e5..c9f1ad3 100644 --- a/MD_STD_IN.php +++ b/MD_STD_IN.php @@ -145,10 +145,10 @@ final class MD_STD_IN { */ final public static function sanitize_url($input):string { - if ($input === "") return $input; + if ($input === "") return ""; $output = \filter_var($input, FILTER_SANITIZE_URL); - if (\filter_var($input, FILTER_VALIDATE_URL) === false) { + if (\filter_var($output, FILTER_VALIDATE_URL) === false) { throw new MDInvalidUrl("Invalid input URL"); } @@ -165,10 +165,10 @@ final class MD_STD_IN { */ final public static function sanitize_email($input):string { - if ($input === "") return $input; + if ($input === "") return ""; $output = \filter_var($input, FILTER_SANITIZE_EMAIL); - if (\filter_var($input, FILTER_VALIDATE_EMAIL) === false) { + if (\filter_var($output, FILTER_VALIDATE_EMAIL) === false) { throw new MDInvalidEmail("Invalid input email address"); }