-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Create missing directories in imageuploader tree if they don't alread… #24878
Create missing directories in imageuploader tree if they don't alread… #24878
Conversation
Hi @hostep. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
Hi @hostep, thank you for your contribution! |
Closed and re-opened PR for that CLA check. |
1d3e03d
to
c8e30a7
Compare
While trying to fix the unit tests, I start to feel like some more things needs to get refactored, because this I'll wait a bit on feedback before continuing this to see if this is the right approach to take to tackle #22609. To sumarize what I think is needed here (behavioral-wise):
|
Thanks for the feedback @kalpmehta! |
@hostep Do you still want to wait for this PR? |
Hi @kalpmehta, thank you for the review. |
@magento run all tests |
✔️ QA Passed |
c8e30a7
to
bd1c3ae
Compare
Rebased PR on top of latest 2.4-develop, to see what the tests will say. Would be great if there could be some feedback on my questions, in the mean while, thanks! |
bd1c3ae
to
c3d1c0d
Compare
c3d1c0d
to
6f81c8c
Compare
6f81c8c
to
99a9405
Compare
Force pushed some more updates (also rebased again on latest 2.4-develop). I'm still not too happy about this, I feel like the original code was not readable enough and it's still not that much improved I think. |
@kalpmehta or somebody else: this can be reviewed again and feedback is welcome :) |
Hi @ihor-sviziev, thank you for the review. |
✔️ QA Passed |
Hi @hostep, thank you for your contribution! |
…y exist.
Description (*)
This is a replacement for #22681
This is partially fixing #22609
I believe we can no longer fully fix #22609 as the bug has existed for too long (2.3.0, 2.3.1, 2.3.2 & 2.3.3 are affected). If people accidentally uploaded images directly in the
pub/media
directory and we fully fix #22609 by changing the storage root, they would no longer be able to access those uploaded images in the wrong directory.This is a fix which creates those missing directories
pub/media/wysiwyg
orpub/media/catalog/category
if the image uploader modal is being opened and those directories don't already exists.Those directories get declared in some xml files (in the
initialMediaGalleryOpenSubpath
node):And then javascript sends those paths in an ajax request using the parameter 'current_tree_path' after which php then creates those directories if they don't already exist.
It would be great if somebody could take a look at this from a security perspective if this is safe enough, or if some extra security precautions should be taken here to make sure javascript can't willy-nilly create all kinds of unwanted directories? It is probably safe enough due to that regex checking, but I'm not 100% sure?
I believe the current code didn't behave like it was originally intended, because these lines are never executed because the
$currentPath
variable only gets set when that directory already exists.I think this problem was probably introduced by some combination of oversights in MAGETWO-87583 and MAGETWO-87986.
/cc @danmooney2, @davemacaulay, @sidolov
Fixed Issues (if relevant)
Manual testing scenarios (*)
pub/media/wysiwyg
andpub/media/catalog/category
don't existQuestions or comments
Contribution checklist (*)