magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Unable to see content in Media folder ending in hyphen #35630

Open edward-simpson opened 2 years ago

edward-simpson commented 2 years ago

Preconditions and environment

Steps to reproduce

  1. Create media folder ending in hyphen (e.g. pub/media/-test-), add images into this folder
  2. Create module and config.xml file to add this folder to WYSIWYG folder list
  3. Navigate to admin panel cms block or page, and try to add image from this folder

Expected result

Images contained in folder display in media gallery to be added into page

Actual result

"No files found" message is displayed

Additional information

This seems to be because of the \b regexp added at the end of the folder path, which stops -test- matching (removing this while testing on regex101.com then matches against the folder name e.g.

-test-\b(?!-)(?:\/?[a-zA-Z0-9\-\_]+)*\/?$

from the full pattern:

^(wysiwyg\b(?!-)(?:\/?[a-zA-Z0-9\-\_]+)*\/?$|-test-\b(?!-)(?:\/?[a-zA-Z0-9\-\_]+)*\/?$|Spec_Sheets\b(?!-)(?:\/?[a-zA-Z0-9\-\_]+)*\/?$)

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @edward-simpson. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 2 years ago

Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:


engcom-Dash commented 2 years ago

hi @edward-simpson , We have tried to reproduce the issue in Magento 2.4-develop branch the issue is not reproducible. Please refer the below screenshot for the reference; Screenshot from 2022-06-24 15-47-04 Screenshot from 2022-06-24 15-46-26

We have followed the below steps in order to reproduce the issue: 1.Create media folder ending in hyphen 2.Create module and config.xml file to add this folder to WYSIWYG folder list 3.Navigate to admin panel cms block or page, and try to add image from this folder

Let us know in case we have missed anything.

Thanks

edward-simpson commented 2 years ago

@engcom-Dash thanks for taking a look, it seems like your replication steps haven't quite matched my issue - the hyphened folder is in the pub root, so, e.g.

/var/html/www/pub/-Retail-/

And appear under the storage root as such:

engcom-Dash commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Dash, here is your Magento Instance: https://189ccb8ce4ff34b4058278913678ea10.instances.magento-community.engineering Admin access: https://189ccb8ce4ff34b4058278913678ea10.instances.magento-community.engineering/admin_8c8a Login: 4032af83 Password: 8fdbf788a298

edward-simpson commented 2 years ago

Hi @engcom-Dash ,

Were you able to replicate this? I appreciate it's not a huge issue for new builds, but I've currently got a client who's now unable to access lots of files in their media folder through the admin panel after an 2.3.4 -> 2.4.3 upgrade

m2-assistant[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 2 years ago

Hello @edward-simpson,

Thanks for the report and collaboration!

We have tried to reproduce the issue on Magento 2.4-develop branch and the issue is reproducible when we use the image folder name with hyphen(-). Please refer to the below screenshot for reference:

image

But without hyphen(-), we can see and select the images from that folder:

image

Hence confirming the issue.

Thanks

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-5901 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

github-jira-sync-bot commented 2 years ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-5901

edward-simpson commented 2 years ago

For anyone else having the issue this patch will solve it, but as I'm unable to guess at the original intention, I can't say whether it will cause any side effects or cause security issues!

diff --git i/Model/Wysiwyg/Images/Storage.php w/Model/Wysiwyg/Images/Storage.php
index 388d0b097..6dd5a04b4 100644
--- i/Model/Wysiwyg/Images/Storage.php
+++ w/Model/Wysiwyg/Images/Storage.php
@@ -1001,7 +1001,7 @@ class Storage extends \Magento\Framework\DataObject
             $or = '';
             foreach($mediaGalleryImageFolders as $folder) {
                 $folderPattern = str_replace('/', '[\/]+', $folder);
-                $regExp .= $or . $folderPattern . '\b(?!-)(?:\/?[a-zA-Z0-9\-\_]+)*\/?$';
+                $regExp .= $or . $folderPattern . '(?!-)(?:\/?[a-zA-Z0-9\-\_]+)*\/?$';
                 $or = '|';
             }
             $regExp .= ')/';
engcom-November commented 1 month ago

Hello @edward-simpson,

As the issue is quite old, we tried to reproduce this in 2.4-develop, and the issue is still reproducible. Please take a look at the screenshot below:

Hence reconfirming this.

Thank you.

github-jira-sync-bot commented 1 month ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-5901