numero2 / contao-proper-filenames

Replaces special characters in filenames right after upload.
https://www.numero2.de/contao/erweiterungen/proper-filenames.html
GNU Lesser General Public License v3.0
13 stars 5 forks source link

Frontend uploads are not inside the Contao root dir #10

Closed rabauss closed 3 years ago

rabauss commented 3 years ago

Unfortunately, for us the uploads in the frontend are not working properly anymore, because files are uploaded to a temporary folder which is not inside the contao root. Because of that the following line will throw an error "/tmp/phpAbc" is not inside the Contao root dir "xyz/contao"

https://github.com/numero2/contao-proper-filenames/blob/ee2812a521eeea7ce416a4e9f9ef53ea62671709/src/Resources/contao/classes/CheckFilenames.php#L104

Has anyone else the same problems or is there a solution to disable the proper filenames for the frontend forms?

rabauss commented 3 years ago

Oh I see there was a related but closed issue https://github.com/numero2/contao-proper-filenames/issues/9 We also use the core upload in a form from the generator!

bennyborn commented 3 years ago

As stated in #9

The Cores widget should always report a tmp_name that's inside TL_ROOT

Maybe @fritzmg could tell us what the problem was in his Installation since this one seems similar?

rabauss commented 3 years ago

Okay, the upload path did not exist in my local dev environment 😭 Because of that the tmp_name is not overwritten here: https://github.com/contao/contao/blob/4.9/core-bundle/src/Resources/contao/forms/FormFileUpload.php#L291

Although I wonder why we have some error logs in our productive system Path \"files/upload\" is not inside the Contao root dir and there the path exists! Maybe I can debug that...

rabauss commented 3 years ago

I cannot reproduce the error in my local environment - so I'm closing this issue for now and need to observe if the error logs continue in our prod system.

bennyborn commented 3 years ago

Thanks @rabauss 🎉

I just made a new release that catches the exception and also adds a checkbox to the backend to prevent certain upload fields from being sanitized at all (if needed).

image