@@ -64,7 +64,7 @@ public function __construct()
6464 */
6565 public function parseMultipartForm (): array
6666 {
67- $ formData = compact ($ this ->post (), $ this ->files ()) ?? [] ;
67+ $ formData = array_merge ($ this ->post (), $ this ->files ());
6868
6969 return $ formData ;
7070 }
@@ -90,7 +90,7 @@ public function getMethod(): ?string
9090 */
9191 public function files (string $ name = null ): ?array
9292 {
93- $ files = isset ($ _FILES ) ? $ this ->getFilteredValue ( $ name , $ _FILES ) : null ;
93+ $ files = isset ($ _FILES ) ? $ this ->h ( $ _FILES ) : null ;
9494
9595 return $ name !== null ? $ files [$ name ] ?? null : $ files ;
9696 }
@@ -480,12 +480,17 @@ private function is_csrf_valid(): bool
480480 */
481481 public function validate (array $ rules , array $ data ): Validator
482482 {
483- $ validator = Validator ::make ($ rules , $ data );
483+ $ validator = $ this -> validator () ::make ($ rules , $ data );
484484 $ validator ->validate ();
485485
486486 return $ validator ;
487487 }
488488
489+ public function validator ()
490+ {
491+ return Validator::getInstance ();
492+ }
493+
489494 /**
490495 * A convenience method that grabs the raw input stream and decodes the JSON into an array.
491496 */
@@ -575,17 +580,15 @@ protected function getFilteredValue(string $key, array $array, $default = null):
575580 }
576581
577582 /**
578- * Shortcut for htmlspecialchars, defaults to the application's charset.
583+ * Filters a value with htmlspecialchars using the application's charset.
579584 */
580- protected function h (string |array $ data , string $ charset = null ): ? string
585+ private function h (string |array $ value , ? string $ charset = null ): string | array
581586 {
582- if (is_string ($ data )) {
583- $ data = htmlspecialchars ($ data , ENT_QUOTES , $ charset ?? config ('app.charset ' ));
584- } elseif (is_array ($ data )) {
585- $ data = array_map ('htmlspecialchars ' , $ data );
587+ if (is_string ($ value )) {
588+ return htmlspecialchars ($ value , ENT_QUOTES , $ charset ?? config ('app.charset ' ));
586589 }
587590
588- return $ data ;
591+ return array_map ([ $ this , ' h ' ], $ value ) ;
589592 }
590593
591594 /**
0 commit comments