cms icon indicating copy to clipboard operation
cms copied to clipboard

Assets don't use the encoded url in control panel

Open DoubleJ-G opened this issue 4 years ago • 9 comments

Bug Description

If you upload an asset with a special character in the file name such as + the control panel will not display or link to the asset correctly. This only effects the control panel, the asset is available using the url encoded file name.

How to Reproduce

Upload/copy a file to assets with a special character

Extra Detail

Example: File+Name.jpg will be encoded and accessible at /assets/File%2BName.jpg but the control panel will try and fetch the unencoded resource path /assets/File+Name.jpg which 404s and won't preview. This also effects the "Open in new window" button.

Environment

Statamic 3.1.34 Pro Laravel 8.55.0 PHP 7.3.27

Install method (choose one):

  • Fresh install from statamic/statamic

DoubleJ-G avatar Aug 20 '21 03:08 DoubleJ-G

Potentially related to https://github.com/statamic/cms/issues/3398 Seems like their might need to be some more testing around asset names?

sjclark avatar Aug 20 '21 04:08 sjclark

Hi @DoubleJ-G, thanks for the report! I am getting different behavior than you are describing. I tried the following with an image named File+Name.jpg:

  1. Upload the file in the Asset Browser -> The asset is renamed to File-Name.jpg and it opens fine in the Asset Editor and via the 'Open in a new window' button.
  2. Place the file using the filesystem in the public/assets folder and reload the Asset Browser -> The asset is still called File+Name.jpg and it opens fine in the Asset Editor and via the 'Open in a new window' button.
  3. I also used the Asset Editor to rename an image without special characters to File+Name.jpg -> The asset is called File+Name.jpg and it opens fine in the Asset Editor and via the 'Open in a new window' button.
  4. For good measure I uploaded a file in the Asset Browser named File%2BName.jpg-> The asset is renamed to File+Name.jpg and it opens fine in the Asset Editor and via the 'Open in a new window' button.

I see that the renaming is not totally consistent, but that is a different issue. I can open all the files in the Control Panel. What should I do differently to make the issue happen?

Tested in Chrome and Safari Statamic 3.1.34 Pro Laravel 8.51.0 PHP 7.4.22

arthurperton avatar Aug 20 '21 13:08 arthurperton

Slugifying would help... statamic/cms#6030

j3ll3yfi5h avatar Oct 07 '21 11:10 j3ll3yfi5h

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

github-actions[bot] avatar Dec 07 '21 01:12 github-actions[bot]

Still an issue...

j3ll3yfi5h avatar Dec 07 '21 07:12 j3ll3yfi5h

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

github-actions[bot] avatar Feb 06 '22 02:02 github-actions[bot]

Still a thing.

j3ll3yfi5h avatar Feb 06 '22 14:02 j3ll3yfi5h

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

github-actions[bot] avatar Apr 08 '22 02:04 github-actions[bot]