Images with ] character in filename don't display properly

AI-generated summary

A user, ron_jeremy, reported that JPG images taken from GoPro videos fail to display or Onebox on their Discourse forum, appearing only as plain URLs — despite working fine on meta and try.discourse.org. The issue was traced not to the file itself (354KB, under size limits) but to an invisible ] character in the alt text generated during upload, which breaks Markdown image syntax. vinothkannans and codinghorror identified that filenames containing ] (e.g., pic].jpg) cause the system to generate malformed Markdown like ![pic]|..., inserting an extra ] that breaks rendering. Manually removing the ] from the alt text resolved the issue for ron_jeremy. codinghorror confirmed the bug and requested that [ and ] be stripped from filenames when generating alt text. The fix was implemented by zogstrip via commit f674b9e, resolving the problem for all users. The issue was not related to plugins, server specs, or rebuilds — purely a filename-to-alt-text parsing edge case.

Video stills taken from GoPro videos are in jpg format. When members try and upload these specific images to my forum they do not Onebox or even display at all (end up as a non-clickable url).

The thing is, they work fine here.

All other images (i.e., non GoPro video stills) work on my forum just fine. Oddly enough, if I take the offending GoPro jpg and export it without making any changes (again, as a jpg) from any image editor then the same image displays just fine.

What am I missing?

Here’s a link to the screencast:

Are those very large size raw images?

354KB – well under the size cap. I can reproduce the issue at will. A couple members that have GoPro’s cannot get any jpg (from still) to work. I was happy to see that the images work fine here, and am hoping I’m just missing a plugin or something. My forum is up to date.

Is it happening here on meta or try.discourse.org as well?

It works fine here on meta, just not on my forum.

AFAIK there is no plugin that handles oneboxing or uploads. That all is built in to discourse.
one question though! Do they not get oneboxed even after you click post/reply?

Yeah, nothing happens – the uploaded image effectively becomes just a ‘dead’ link, like this:

![09]|690x388](upload://uzG6vZHkaFDx5K44ci8JKxqweZX.jpg)

Looks like your filename having the ] symbol. Try again by removing it.

7 Likes

The file name is GP067894.jpg.

Can you provide a link so we can download a GoPro video still? I’m curious if there’s anything inherently different from other JPGs.

4 Likes

Sure, below is the image as uploaded to my Dropbox.

Remember, the image works fine on this forum but not on my forum, where it only shows the URL (as illustrated in the first post of this thread:

http://forum.singletrackbc.com/t/out-for-a-rip-with-al/758

Again, to my knowledge, this only happens with jpg’s shot with a GoPro.

Is your site on latest code, like try and meta are?

Just checked 2.0.0.beta1+93

Have you rebuilt at the command line recently? You need that to get the latest container, etc. If we can’t repro this on try or meta, it’s not a bug in Discourse by definition.

Pardon my ignorance, but does that mean running this?

./launcher rebuild app

2 Likes

git pull beforehand, in the correct directory, but yes :wink:

All done. I also ran OS updates and upgrades, then upgraded the Droplet to the new pricing plan specs (4GB/2CPU/80GB). Unfortunately, the same issue happens when I try to upload the exact same image that was uploaded (and working) in this thread.

When trying to insert the image the result is simply a line of plain text:

![31]|690x387](upload://nAo0GVB2DXSk484vgstfhPG1BQv.jpg)

I have no idea why this is happening.

It’s the extra closing square bracket, wherever that is coming from.
![31|690x387](upload://nAo0GVB2DXSk484vgstfhPG1BQv.jpg)

4 Likes

What closing bracket? The file name is GP067894.jpg

Not the filename, the insertion text:

![31]|690x387](upload://nAo0GVB2DXSk484vgstfhPG1BQv.jpg)
----^

Do you see the character I have marked above with the ^ caret? It is incorrect.

In the above example the filename of the image I uploaded was ..

http-error-404-not-found.jpg

.. on disk which results in

![http-error-404-not-found|499x499](upload://jw2BCroZfVX1dZChRVVvApQAjrh.jpg)

Your image, on disk, must have ] in the filename and this is causing problems:

bad filename].jpg

Perhaps this is a bug in Discourse, we should probably remove those bracket characters @vinothkannans as they are valid in filenames at least in Windows, and we are only using them for the alt text anyway.

5 Likes