RTC bug PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
7 Sep 2026

Pull Request resolves #48384.

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

Currently, there is error when extract zip file in template manager as described at #48384. This PR fixes that error. The PR also improve quality of the existing code and added necessary Path::check when it is needed to avoid path traversal (both from the path of the archive file and also path of the extracted files)

Testing Instructions

  • Uses Joomla 5.4
  • Access to Template Manger, edit a template and upload a zip file there (the zip file must not contains php files, otherwise, it will be blocked by Joomla during upload)
  • Try to unzip that file

Actual result BEFORE applying this Pull Request

There is error as described at #48384

Expected result AFTER applying this Pull Request

No error anymore, zip file is extracted properly. If there is existing file with the file in the zip file, you will get error messages such as "Some files with the same name already exist." and "Failed to extract the archive file." , this is expected (and existing behavior, before this PR)

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar joomdonation joomdonation - open - 7 Sep 2026
avatar joomdonation joomdonation - change - 7 Sep 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 7 Sep 2026
Category ⇒ Administration com_templates
avatar richard67 richard67 - test_item - 7 Sep 2026 - Tested successfully
avatar richard67
richard67 - comment - 7 Sep 2026

I have tested this item ✅ successfully on a017d12

I've successfully reproduced the issue and tested the fix as described.

In addition, I have successfully tested that when a file which shall be extracted already exists - this can be easily tested by just trying to extract the zip file a 2nd time - then the extraction fails with error alerts "Some files with the same name already exist." and "Failed to extract the archive file.".

@joomdonation Could you add that to the testing instructions so other testers will test that, too? Thanks in advance.


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

avatar richard67
richard67 - comment - 7 Sep 2026

I have tested this item ✅ successfully on a017d12

I've successfully reproduced the issue and tested the fix as described.

In addition, I have successfully tested that when a file which shall be extracted already exists - this can be easily tested by just trying to extract the zip file a 2nd time - then the extraction fails with error alerts "Some files with the same name already exist." and "Failed to extract the archive file.".

@joomdonation Could you add that to the testing instructions so other testers will test that, too? Thanks in advance.


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

avatar richard67
richard67 - comment - 7 Sep 2026

I have tested this item ✅ successfully on a017d12

I've successfully reproduced the issue and tested the fix as described.

In addition, I have successfully tested that when a file which shall be extracted already exists - this can be easily tested by just trying to extract the zip file a 2nd time - then the extraction fails with error alerts "Some files with the same name already exist." and "Failed to extract the archive file.", and nothing is extracted from that archive, also no other files.

@joomdonation Could you add that to the testing instructions so other testers will test that, too? Thanks in advance.


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

avatar joomdonation
joomdonation - comment - 7 Sep 2026

Could you add that to the testing instructions so other testers will test that, too

@richard67 This is existing behavior and not being changed by this PR, so I do not mention it in the testing instructions.

avatar joomdonation joomdonation - change - 7 Sep 2026
The description was changed
avatar joomdonation joomdonation - edited - 7 Sep 2026
avatar richard67
richard67 - comment - 7 Sep 2026

Could you add that to the testing instructions so other testers will test that, too

@richard67 This is existing behavior and not being changed by this PR, so I do not mention it in the testing instructions.

@joomdonation Yes, but you have fixed that, too. Before it would have failed, too, just it would not be testable because of the first error. But now with your PR it works. So I thought it could be worth to be mentioned.

Anyway, I am ok with it.

avatar richard67
richard67 - comment - 7 Sep 2026

P.S.: In addition, I have also tested that trying to upload a crafted Zip file which contains a file with a relative path "../../escaped.txt" (path traversal) is not possible (exception thrown by Path::check).

avatar brianteeman brianteeman - test_item - 7 Sep 2026 - Tested successfully
avatar brianteeman
brianteeman - comment - 7 Sep 2026

I have tested this item ✅ successfully on a017d12

tested with a zip file containing files and folders


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

avatar brianteeman
brianteeman - comment - 7 Sep 2026

I have tested this item ✅ successfully on a017d12

tested with a zip file containing files and folders


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

avatar richard67 richard67 - change - 7 Sep 2026
Status Pending ⇒ Ready to Commit
Labels Added: bug PR-5.4-dev
avatar richard67
richard67 - comment - 7 Sep 2026

RTC


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

avatar richard67
richard67 - comment - 7 Sep 2026

RTC


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

avatar brianteeman
brianteeman - comment - 7 Sep 2026

what is the expected behaviour when you try to upload a zip file with php files inside it

avatar richard67
richard67 - comment - 7 Sep 2026

what is the expected behaviour when you try to upload a zip file with php files inside it

@brianteeman Currently it shows red alert messages "No file was found." and "Failed to upload file.". That can be improved for sure, but right now that's the expected behavior.

avatar muhme
muhme - comment - 8 Sep 2026

@joomdonation Thank you for your speedy fix 👍 and I am wondering that I get success and error message:
shoot
Tested with JBT, PHP 8.5 in creating simplest ZIP with one image:

cd images
zip ../media/templates/site/cassiopeia/images/test.zip powered_by.png
zipinfo ../media/templates/site/cassiopeia/images/test.zip powered_by.png 
-rw-r--r--  3.0 unx     3197 bx stor 26-Sep-08 17:25 powered_by.png

'File Content Preview' lists the one image file name.
'Extract Here' extracts the image and I am getting success message Archive file extracted., but additional an error message Archive file not found.?

avatar joomdonation
joomdonation - comment - 8 Sep 2026

@muhme From the code, I could not guess how you get both success and error message like that. Can you test it again with a different zip file, maybe with a fresh Joomla 5.4 installation?

avatar muhme
muhme - comment - 8 Sep 2026

@muhme From the code, I could not guess how you get both success and error message like that. Can you test it again with a different zip file, maybe with a fresh Joomla 5.4 installation?

It was the second ZIP file and it was fresh 5.4-dev branch installation. Used Patch Tester. I will try full installation from PR's Download and test ZIP with multiple files ...

avatar joomdonation
joomdonation - comment - 8 Sep 2026

Can you upload the zip file which you are using for testing so that I can try to test it myself with your file, too ?

avatar muhme
muhme - comment - 8 Sep 2026

@joomdonation Same result (success + error message) with PR's full packages installation, different ZIP containing multiple images, using 7-Zip instead Apple-compiled zip, Joomla debug disabled or using Safari instead of Firefox. No Joomla or PHP log entries.

avatar muhme
muhme - comment - 8 Sep 2026

Can you upload the zip file which you are using for testing so that I can try to test it myself with your file, too ?

test.zip

avatar joomdonation
joomdonation - comment - 9 Sep 2026

I tried with your file (which is a very simple zip file) but for some reasons, I could not replicate the errors you are having here, so strange. Is your test site public accessible? If Yes, can you give me access so that I can try it directly on your test site. Will send you a message on Mattermost.

avatar muhme muhme - change - 9 Sep 2026
Status Ready to Commit ⇒ Pending
avatar muhme
muhme - comment - 9 Sep 2026

Set back to Pending as there is an error message in sub-folders


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

avatar muhme
muhme - comment - 9 Sep 2026

Set back to Pending as there is an error message in sub-folders


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

avatar brianteeman
brianteeman - comment - 9 Sep 2026

I just tried with your zip. Uploading it into various different folders and then extracting it - no problem here

avatar joomdonation
joomdonation - comment - 9 Sep 2026

Turned out it is another bug. The error @muhme found happens when we extract a file in media folder. It should be fixed now with my last commit. Could you please test it again? Thanks

avatar brianteeman
brianteeman - comment - 9 Sep 2026

@joomdonation how do i replicate the problem?

avatar joomdonation
joomdonation - comment - 9 Sep 2026

@brianteeman Please upload the zip file to media/templates/site/cassiopeia , then select that file and extract it from there
file

avatar brianteeman brianteeman - test_item - 9 Sep 2026 - Tested successfully
avatar brianteeman
brianteeman - comment - 9 Sep 2026

I have tested this item ✅ successfully on 3641e47

I have verified the additional error reported by @muhme and confirm that the latest addition to this PR fixes it


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

avatar brianteeman
brianteeman - comment - 9 Sep 2026

I have tested this item ✅ successfully on 3641e47

I have verified the additional error reported by @muhme and confirm that the latest addition to this PR fixes it


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

avatar richard67 richard67 - test_item - 9 Sep 2026 - Tested successfully
avatar richard67
richard67 - comment - 9 Sep 2026

I have tested this item ✅ successfully on 3641e47

In addition to my previous test, I've successfully verified the issue found by @muhme and tested the fix.


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

avatar richard67
richard67 - comment - 9 Sep 2026

I have tested this item ✅ successfully on 3641e47

In addition to my previous test, I've successfully verified the issue found by @muhme and tested the fix.


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

avatar richard67 richard67 - change - 9 Sep 2026
Status Pending ⇒ Ready to Commit
avatar richard67
richard67 - comment - 9 Sep 2026

RTC


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

avatar richard67
richard67 - comment - 9 Sep 2026

RTC


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

avatar richard67 richard67 - change - 9 Sep 2026
Labels Added: RTC
avatar muhme
muhme - comment - 10 Sep 2026

✅ Final test before merge with JBT

  • Seen the two red error messages in extracting ZIP before PR
  • Applied PR with Patch Tester
    • Extracting ZIP with one image is working in templates and also in media folder
    • Extracting ZIP with multiple files and subdirectories is working in templates and also in media folder
    • Extraction of file-system copied ZIP archive with relative paths ../../../../tmp/hello-world.php fails with exception Joomla\Filesystem\Path::check() - Use of relative paths not permitted
    • Extracting archive with already existing files fails with error Some files with the same name already exist.
    • No unusual Joomla or PHP log messages except the named exception and
      • Not related to this PR: On the attempt to upload a ZIP archive with relative paths fails with red error message and there are:
        • PHP Warning: Trying to access array offset on null in /var/www/html/administrator/components/com_templates/src/Model/TemplateModel.php on line 1389
        • PHP Deprecated: transliterator_transliterate(): Passing null to parameter # 2 ($string) of type string is deprecated in /var/www/html/libraries/vendor/joomla/filesystem/src/File.php on line 95
avatar muhme muhme - change - 10 Sep 2026
Status Ready to Commit ⇒ Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 ⇒ 2026-09-10 11:57:35
Closed_By ⇒ muhme
avatar muhme muhme - close - 10 Sep 2026
avatar muhme muhme - merge - 10 Sep 2026
avatar muhme
muhme - comment - 10 Sep 2026

Thank you very much @joomdonation for your speedy fix. Thanks to @brianteeman and @richard67 for testing multiple times.

avatar joomdonation
joomdonation - comment - 10 Sep 2026

Thanks

Add a Comment

Login with GitHub to post a comment