File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed
Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 11# Release Notes for Snaptcha
22
3+ ## 5.1.2 - 2025-07-01
4+
5+ - Improved the check for nested uploaded file fields.
6+
37## 5.1.1 - 2025-06-23
48
59- Improved the check for uploaded files.
Original file line number Diff line number Diff line change 11{
22 "name" : " putyourlightson/craft-snaptcha" ,
33 "description" : " Automatically validates forms and prevents spam bots from submitting to your site." ,
4- "version" : " 5.1.1 " ,
4+ "version" : " 5.1.2 " ,
55 "type" : " craft-plugin" ,
66 "homepage" : " https://putyourlightson.com/plugins/snaptcha" ,
77 "license" : " proprietary" ,
Original file line number Diff line number Diff line change @@ -100,10 +100,10 @@ public function hasFileUpload(): bool
100100 foreach ($ _FILES as $ file ) {
101101 $ error = $ file ['error ' ] ?? null ;
102102 if (is_array ($ error )) {
103- if (in_array ( UPLOAD_ERR_OK , $ error, true )) {
103+ if ($ this -> hasUploadedFileRecursive ( $ error )) {
104104 return true ;
105105 }
106- } elseif ($ error === UPLOAD_ERR_OK ) {
106+ } elseif ($ error !== UPLOAD_ERR_NO_FILE ) {
107107 return true ;
108108 }
109109 }
@@ -366,6 +366,24 @@ private function getNormalizedArray(array|string $values): array
366366 return $ values ;
367367 }
368368
369+ /**
370+ * Returns whether the request has a file upload by recursively checking.
371+ */
372+ private function hasUploadedFileRecursive (array $ errors ): bool
373+ {
374+ foreach ($ errors as $ error ) {
375+ if (is_array ($ error )) {
376+ if ($ this ->hasUploadedFileRecursive ($ error )) {
377+ return true ;
378+ }
379+ } elseif ($ error !== UPLOAD_ERR_NO_FILE ) {
380+ return true ;
381+ }
382+ }
383+
384+ return false ;
385+ }
386+
369387 /**
370388 * Flattens a multi-dimensional array of values to a flat array that can
371389 * be used to output hidden fields, preserving the keys.
You can’t perform that action at this time.
0 commit comments