@@ -16,7 +16,7 @@ class Request
1616 */
1717 public static function get (string $ name )
1818 {
19- return $ _REQUEST [$ name ] ?? null ;
19+ return str_replace ([ '\'' , ' " ' ], [ '\\\'' , '\\ " ' ], $ _REQUEST [$ name ]) ?? null ;
2020 }
2121
2222 /**
@@ -36,7 +36,7 @@ public static function getInt(string $name, int $min = null, int $max = null)
3636 'flags ' => FILTER_FLAG_ALLOW_OCTAL
3737 ];
3838
39- return filter_var ($ _REQUEST [ $ name] , FILTER_VALIDATE_INT , $ options );
39+ return filter_var (self :: get ( $ name) , FILTER_VALIDATE_INT , $ options );
4040 }
4141
4242 /**
@@ -45,7 +45,7 @@ public static function getInt(string $name, int $min = null, int $max = null)
4545 */
4646 public static function getEmail (string $ name )
4747 {
48- return filter_var ($ _REQUEST [ $ name] , FILTER_VALIDATE_EMAIL ) ?: '' ;
48+ return filter_var (self :: get ( $ name) , FILTER_VALIDATE_EMAIL ) ?: '' ;
4949 }
5050
5151 /**
@@ -60,9 +60,7 @@ public static function getArgs(string $class, string $method): array
6060 $ reflection = new ReflectionMethod ($ class , $ method );
6161
6262 foreach ($ reflection ->getParameters () AS $ arg ) {
63- if ($ _REQUEST [$ arg ->name ]) {
64- $ args [$ arg ->name ] = $ _REQUEST [$ arg ->name ] ?? null ;
65- }
63+ $ args [$ arg ->name ] = self ::get ($ arg ->name ) ?? null ;
6664 }
6765
6866 return $ args ;
0 commit comments