Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure `accept_file_types` is an INDEXED array, and disallow certain filetypes to be whitelisted #7768

Merged
merged 10 commits into from Apr 11, 2019

CS fixes

  • Loading branch information...
bobdenotter committed Apr 4, 2019
commit c84e8ba4ab9343b9dd83f87c4ceee97bbb3edac8
@@ -315,14 +315,14 @@ protected function parseGeneral()
// Create a bag with lowercased extensions
$bag = Bag::from($general['accept_file_types']);
$bag = $bag->map(function($key, $ext) use ($removeFromAllowedFileTypes) {
$bag = $bag->map(function ($key, $ext) use ($removeFromAllowedFileTypes) {
if (!in_array(mb_strtolower($ext), $removeFromAllowedFileTypes)) {
return mb_strtolower($ext);
}
This conversation was marked as resolved by bobdenotter

This comment has been minimized.

Copy link
@JarJak

JarJak Apr 5, 2019

Member

else return null

})->clean();
// Set accept_file_types, with the previous bag _and_ uppercased alternatives.
This conversation was marked as resolved by bobdenotter

This comment has been minimized.

Copy link
@JarJak

JarJak Apr 11, 2019

Member

Outdated comment

This comment has been minimized.

Copy link
@bobdenotter

bobdenotter Apr 11, 2019

Author Member

fixed

$general['accept_file_types'] = $bag->merge($bag->map(function($key, $ext) {
$general['accept_file_types'] = $bag->merge($bag->map(function ($key, $ext) {
return mb_strtoupper($ext);
}))->toArray();

This comment has been minimized.

Copy link
@JarJak

JarJak Apr 5, 2019

Member

However .pHp will still pass this firewall. strtolower should be done while checking extensions, not while building the list (maybe change it in separate PR?)

This comment has been minimized.

Copy link
@bobdenotter

bobdenotter Apr 5, 2019

Author Member

it actually does that too. See line 319..

Example:

Schermafbeelding 2019-04-05 om 13 00 51

Result:

Schermafbeelding 2019-04-05 om 13 01 32

This comment has been minimized.

Copy link
@JarJak

JarJak Apr 5, 2019

Member

So, if jpg is on this list, will .jPG be accepted too?

}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.