? Success
Pull Request for # 7813

User tests: Successful: Unsuccessful:

avatar ryandemmer
ryandemmer
4 Sep 2015

With reference to issue #7813

array_reverse returns the reversed array, it does not change the original array.


Line 441 to 444 of libraries/joomla/filter/JInputFilter.php extracts possible extensions in the file name to check against a list of invalid extensions.

https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/filter/input.php

On line 442, array_reverse is used to re-arrange the array created so as to move the file name to the end, removing it with array_pop on line 443, but array_reverse returns the re-ordered array, it does not change the original array - http://php.net/manual/en/function.array-reverse.php

Therefore line 442 should be:

$explodedName = array_reverse($explodedName);

avatar ryandemmer ryandemmer - open - 4 Sep 2015
avatar ryandemmer ryandemmer - change - 4 Sep 2015
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Sep 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 5 Sep 2015
Category Libraries
avatar zero-24
zero-24 - comment - 5 Sep 2015

Tested successfull with this script.

<?php
$intendedName = 'download.xml';
$explodedName = explode('.', $intendedName);
array_reverse($explodedName);
// $explodedName = array_reverse($explodedName);
array_pop($explodedName);
array_map('strtolower', $explodedName);

print_r($explodedName);

This return: Array ( [0] => download )

If we change the script to:

<?php
$intendedName = 'download.xml';
$explodedName = explode('.', $intendedName);
// array_reverse($explodedName);
$explodedName = array_reverse($explodedName);
array_pop($explodedName);
array_map('strtolower', $explodedName);

echo $explodedName;
print_r($explodedName);

It returns Array ( [0] => xml ).

Thanks.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7814.

avatar zero-24 zero-24 - test_item - 5 Sep 2015 - Tested successfully
avatar roland-d roland-d - change - 6 Sep 2015
Rel_Number 0 7813
Relation Type Pull Request for
avatar joomdonation
joomdonation - comment - 7 Sep 2015

Test : Success.

The original code is clearly wrong and making file extension check doesn't work properly (instead of removing file name from array, it actually removes the file extension, so file extension is not being checked/validated with $options['forbidden_extensions']). This PR just correct it.

avatar zero-24 zero-24 - change - 7 Sep 2015
Status Pending Ready to Commit
avatar zero-24
zero-24 - comment - 7 Sep 2015

Setting RTC. Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7814.

avatar joomla-cms-bot joomla-cms-bot - change - 7 Sep 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 7 Sep 2015
Milestone Added:
avatar Kubik-Rubik Kubik-Rubik - change - 7 Sep 2015
Milestone Added:
avatar Kubik-Rubik Kubik-Rubik - change - 7 Sep 2015
Milestone Removed:
avatar Kubik-Rubik Kubik-Rubik - test_item - 7 Sep 2015 - Tested successfully
avatar Kubik-Rubik
Kubik-Rubik - comment - 7 Sep 2015

Thank you @ryandemmer! It's important enough to be merged in the RC version, merging by code review.

avatar Kubik-Rubik Kubik-Rubik - reference | 805dbc3 - 7 Sep 15
avatar Kubik-Rubik Kubik-Rubik - merge - 7 Sep 2015
avatar Kubik-Rubik Kubik-Rubik - close - 7 Sep 2015
avatar Kubik-Rubik Kubik-Rubik - change - 7 Sep 2015
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2015-09-07 06:44:23
Closed_By Kubik-Rubik
avatar Kubik-Rubik Kubik-Rubik - close - 7 Sep 2015
avatar joomla-cms-bot joomla-cms-bot - close - 7 Sep 2015
avatar joomla-cms-bot joomla-cms-bot - change - 7 Sep 2015
Labels Removed: ?
avatar 810
810 - comment - 8 Sep 2015

We have now a regression on installing Kunena 3rt party templates:

Missing file to extract:

How to reproduce:

  • install kunena
  • download crypsisb3 www.kunena.org/download
  • go to backend - kunena - template manager - new template
  • select template and click on upload file and install

Extra info
our code: https://github.com/Kunena/Kunena-Forum/blob/develop/components/com_kunena/admin/controllers/templates.php#L98

avatar Bakual
Bakual - comment - 9 Sep 2015

@810 Reason is likely that you want to upload a file with a forbidden extension (eg ".php") then. That check was supposed to work since 3.4.0, but was broken.
If you use JFile::upload, you have to set the $allow_unsafe argument to true or explicitely pass $safeFileOptions with the correct options.

avatar joomdonation
joomdonation - comment - 9 Sep 2015

Hmm

I have same issue with my extension. I think you will need to modify code in the line 103

file = $this->app->input->files->get('install_package');

To

file = $this->app->input->files->get('install_package', null, 'raw');

The reason is because this block of code https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/input/files.php#L81-L89

avatar Kubik-Rubik
Kubik-Rubik - comment - 9 Sep 2015

As @Bakual said, this was a bug since 3.4.0 and was fixed finally in the version 3.4.4. Please use the raw parameter to suppress the safe file check.

avatar joomdonation
joomdonation - comment - 9 Sep 2015

I just wanted to point out the needed changes. There are two changes needed:

  1. Use raw filter as I mentioned above.

  2. If we use JFile::upload, we will have to set the $allow_unsafe argument to true or explicitely pass $safeFileOptions with the correct options as @Bakual mentioned.

avatar Kubik-Rubik
Kubik-Rubik - comment - 9 Sep 2015

@joomdonation Correct! Thank you for pointing it out.

avatar 810
810 - comment - 9 Sep 2015

ok, thnx we had that before, only without the allow_unsafe. We changed that. Now its working again.

Add a Comment

Login with GitHub to post a comment