FriendsOfFlarum / upload

The file upload extension with insane intelligence for your Flarum forum.
https://discuss.flarum.org/d/4154
MIT License
175 stars 94 forks source link

Text files cannot be previewed correctly #308

Closed ianchb closed 1 year ago

ianchb commented 2 years ago

Text files cannot be previewed correctly


I‘ve just updated the extension and tried to use the text preview template. image


  1. Then, I uploaded a long(>5 lines) .txt file but I didn't see "Expand/Collapse Preview" button.

image When I changed the _hassnippet into true, image I saw this in preview: image But after saving the post, It seems that nothing has changed: image


  1. Next, I uploaded a shorter(3 lines) file and this happened: image After I click the button, nothing happens except the button text changes. image
krodelabestiole commented 1 year ago

Hi, I face the same issue.

I get this message in the HTML code (div class FofUpload-TextPreviewError) : Error previewing file. It may have been deleted, or the provided file ID is invalid. It might not be related however since this div is not visible...

Here's an example : https://ufr-forum.crachecode.net/d/2062897-test-transfets-de-fichiers/12

The JavaScript still retrieves the link to the file : https://ufr-forum.crachecode.net/assets/files/2023-02-22/1677049996-661418-code.txt

This forum is a bit modified version of flarum but I have the same issue with a brand new one, using crazymax/flarum:latest

flarum v 1.6.2 fof/upload v 1.2.3 (in both cases)

Any help would be much appreciated !

krodelabestiole commented 1 year ago

ok I've got it ! (at least in my case)

The whole topic content is inside a noscript tag : <noscript id="flarum-content">

thus the inline <script> written just after the uploaded text preview won't be executed !

I guess it's a security method. I wonder how we could fix that not putting the website users at risk.