From 39bdb3f1a4b70fa3d6ae63b24990c34bbbb6eaf1 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 22 Feb 2023 15:32:35 -0500 Subject: [PATCH] Added find_get_field. --- src/bootstrap/safer_io.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/safer_io.php b/src/bootstrap/safer_io.php index 3c8b7e3..e9baba2 100644 --- a/src/bootstrap/safer_io.php +++ b/src/bootstrap/safer_io.php @@ -296,7 +296,7 @@ final class safer_io { return $item; } - private static function find_post_field(string $input_field_name) { + private static function find_post_field(string $input_field_name): mixed { $content_type = self::get_clean_server_var('CONTENT_TYPE'); if ($content_type === null) { return false; @@ -315,6 +315,18 @@ final class safer_io { } return false; } + + private static function find_get_field(string $input_field_name): mixed { + if (isset($_SERVER['QUERY_STRING'])) { + $query = self::get_clean_server_var('QUERY_STRING'); + $get = []; + parse_str($query, $get); + if (isset($get[$input_field_name])) { + return $get[$input_field_name]; + } + } + return false; + } private static function get_input_by_type( string $input_field_name, @@ -336,9 +348,13 @@ final class safer_io { if ($is_set) { return filter_input(INPUT_POST, $input_field_name); } - if (!filter_has_var(INPUT_GET, "debugging")) { + if (!self::find_get_field("debugging")) { return null; } + $get_var = self::find_get_field($input_field_name); + if ($get_var !== false) { + return $get_var; + } $is_get_set = filter_has_var(INPUT_GET, $input_field_name); if ($is_get_set) { return filter_input(INPUT_GET, $input_field_name); @@ -352,6 +368,12 @@ final class safer_io { } return null; } + if ($input_type === INPUTS::get) { + $get_var = self::find_get_field($input_field_name); + if ($get_var !== false) { + return $get_var; + } + } $resolve_input = $input_type->resolve(); $is_set = filter_has_var($resolve_input, $input_field_name); if ($is_set) {