Skip to content

Commit 9bffa52

Browse files
committed
Sync.
3 parents da8fa89 + 3f9fb9b + 11cdec0 commit 9bffa52

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
4848

4949
### v3.3.0
5050

51-
[2022.09.26; New Feature; Maikuolan]: Custom headers/footers for front-end pages and the upload denied page now be set directly via configuration.
51+
[2022.09.26; New Feature; Maikuolan]: Custom headers/footers for front-end pages and the upload denied page can now be set directly via configuration.
52+
53+
[2022.10.12; BaseMax]: Improved L10N for Persian/Farsi.
54+
55+
[2022.10.13; Bug-fix; ben-mckenzie]: The scan function was incorrectly detecting file spoofing when associative or nested structures were present in `$_FILES` (e.g. `foo['bar'][]`); Fixed.

src/Web.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,25 @@ public function scan()
150150

151151
/** Normalise the structure of the files array. */
152152
foreach ($_FILES as $fileData) {
153-
if (is_array ($fileData['name'])) {
154-
array_walk_recursive($fileData['name'], function($item, $key) use (&$FilesData) {
153+
/** Guard. */
154+
if (!isset($fileData['error'])) {
155+
continue;
156+
}
157+
158+
if (is_array($fileData['name'])) {
159+
array_walk_recursive($fileData['name'], function ($item, $key) use (&$FilesData) {
155160
$FilesData['name'][] = $item;
156161
});
157-
array_walk_recursive($fileData['type'], function($item, $key) use (&$FilesData) {
162+
array_walk_recursive($fileData['type'], function ($item, $key) use (&$FilesData) {
158163
$FilesData['type'][] = $item;
159164
});
160-
array_walk_recursive($fileData['tmp_name'], function($item, $key) use (&$FilesData) {
165+
array_walk_recursive($fileData['tmp_name'], function ($item, $key) use (&$FilesData) {
161166
$FilesData['tmp_name'][] = $item;
162167
});
163-
array_walk_recursive($fileData['error'], function($item, $key) use (&$FilesData) {
168+
array_walk_recursive($fileData['error'], function ($item, $key) use (&$FilesData) {
164169
$FilesData['error'][] = $item;
165170
});
166-
array_walk_recursive($fileData['size'], function($item, $key) use (&$FilesData) {
171+
array_walk_recursive($fileData['size'], function ($item, $key) use (&$FilesData) {
167172
$FilesData['size'][] = $item;
168173
});
169174
} else {
@@ -176,10 +181,9 @@ public function scan()
176181
}
177182

178183
$FilesCount = count($FilesData['error']);
179-
184+
180185
/** Iterate through normalised array and scan as necessary. */
181186
for ($Iterator = 0; $Iterator < $FilesCount; $Iterator++) {
182-
183187
if (!isset($FilesData['name'][$Iterator])) {
184188
$FilesData['name'][$Iterator] = '';
185189
}
@@ -219,7 +223,6 @@ public function scan()
219223
continue;
220224
}
221225

222-
223226
/** Protection against upload spoofing (1/2). */
224227
if (
225228
!$FilesData['name'][$Iterator] ||
@@ -268,7 +271,7 @@ public function scan()
268271
/** Designate as scan target. */
269272
$FilesToScan[$FilesData['name'][$Iterator]] = $FilesData['tmp_name'][$Iterator];
270273
}
271-
274+
272275
/** Check these first, because they'll reset otherwise, then execute the scan. */
273276
if (!count($this->Loader->ScanResultsText) && count($FilesToScan)) {
274277
$this->Scanner->scan($FilesToScan, 4);

0 commit comments

Comments
 (0)