locomotivecms / wagon

Wagon is a command line tool that let's you develop for Locomotive right on your local machine.
https://www.locomotivecms.com
MIT License
188 stars 117 forks source link

Special characters in file names get url encoded on wagon sync #379

Open dotsi opened 5 years ago

dotsi commented 5 years ago

There are two separate parts to this issue:

wagon sync while creating a local copy of the user uploaded assets encodes all special characters in file names. It does so for the actual file names under public/samples/_env/... and also in the json definition under data/public/... File named migration@2x.png becomes migration%402x.png The expected behavior would be to leave the file names as they are. If they work on the engine they should work locally.

wagon deploy -d has a separate issue where it cuts off the name of the file if it contains the character % and produces an error because a file with this name doesn’t exist. It looks for a file named migration Instead of migration%402x.png

Both issues work together to prevent pushing files previously synced from the engine where users used special chars in uploaded file names.

dotsi commented 5 years ago

I tried renaming the file and its reference from migration%402x.png back to migration@2x.png and wagon deploy -d produced the sam error. So it also cuts off at the @ char. Renaming the file to migration-2x.png works as expected.

dotsi commented 5 years ago

And _ (underscore) in the name breaks the deployment too. So my guess is any non url compatible char breaks it.

did commented 4 years ago

@dotsi I've started to look at it. First, theme assets work fine with "xxx@2x.png" files, at least with Wagon 3.0 and Engine 4.0. The issue is about the sections (+ content entries I guess). When you upload + set an image of a section field, we use the url of the file. It turns out that Carrierwave escapes characters like @ which apparently seems to be the right choice. I don't like the idea of unescaping the image urls in Engine. The only option is to unescape filenames of assets when syncing a site.

dotsi commented 4 years ago

@did Yes this only affects files uploaded trough the various cms interfaces, not theme files. I am not sure I understand what you propose as a solution. The goal would be that the file names stay intact when syncing/deploying content. Ideally the file names would not change, but if they need to it is still beter then the situation now where it does not work as soon as the filename contains chars that get escaped. If the filenames can be unescaped before the sync command saves the files, this should solve the issue?