tinyfilemanager icon indicating copy to clipboard operation
tinyfilemanager copied to clipboard

Impossible to edit an empty file with certain file extensions

Open ungive opened this issue 2 years ago • 3 comments

I have tested this with the docker image tagged "master" (from Feb 26 2023), logged in as the default admin user (command used: sudo docker run -d -v /media/jonas/renkforce/USERDATA/Minecraft/tinyfilemanager/:/var/www/html/data -p 80:80 --restart=always --name tinyfilemanager tinyfilemanager/tinyfilemanager:master)

I created a new file via the "New Item" button in the header with the name "test.mcfunction". Upon clicking on this file I noticed there is no "Edit" or "Advanced Editor" button. This button exists with other plaintext files (e.g. txt).

Attempting to edit it by using the edit URL for this file yields an empty page with no options to edit the file (http://localhost/index.php?p=data&edit=test.mcfunction).

How can I edit this file through tinyfilemanager, without downloading and uploading it again?

I think all files that aren't definitely binary files should be editable, even if their file extension is unknown.

ungive avatar Mar 06 '23 16:03 ungive

add your file extension to https://github.com/prasathmani/tinyfilemanager/blob/master/tinyfilemanager.php#L2972

prasathmani avatar Mar 07 '23 05:03 prasathmani

Thanks for the response! I already did that as a temporary workaround, but personally, I would suggest to go for a more permanent solution, where the choice of files that get to be edited is less restrictive and more permissive.

Known binary file MIME types (like "application/octet-stream", "video/x-matroska", ...) should be disallowed for text editing, but anything that is plain text ("text/plain" or "application/x-empty" for empty files) should be editable. The PHP mime_content_type function tries to guess the MIME type just from the content, without hard-coding file extensions.

ungive avatar Mar 07 '23 11:03 ungive

I do agree. Tested PR #988 and it works fine with 2.5.3 (but tested with copy/paste the changes).

nerun avatar May 26 '24 17:05 nerun