zikula-modules / Files

File Manager for Zikula
13 stars 2 forks source link

files and folders with spaces fail #9

Open robbrandt opened 10 years ago

robbrandt commented 10 years ago

I experienced this with moving files from one folder to another, but I remember from a previous project that this happens in several places. That project was a controlled user base, whereas my current one is not. Not reasonable to tell users not to put spaces in the names.

jguille2 commented 10 years ago

Yes, you're right. There are problems in moving, ziping, inserting... with this filenames.

See if we can fix it.

espaan commented 10 years ago

There might be formatforOS kind of calls missing then, These should convert names into OS safe names. FileUtil does this for instance on mkdirs and so. https://github.com/zikula/core/blob/1.3/src/lib/util/FileUtil.php#L269 https://github.com/zikula/core/blob/1.3/src/lib/util/DataUtil.php#L381

jguille2 commented 10 years ago

I have a question ...

Certainly this is a bug issue, so the module should have a uniform behavior. Today in upload whitespaces are transformed into '_' ... but then rename function allow these whitespaces.

The question is: should allow filenames can have whitespaces? We use this module to make public urls (like an static web). Obviously spaces can be encoded (% 20), but this is not the idea of the module, which allows a direct referencing (for example, "file=users/a/admin/forums_css_1.png" ).

What about this?

If whitespaces are not allowed ... we just have to force transformation (' ' into '_') in all cases (unzip and rename functions).

robbrandt commented 10 years ago

Your questions arise from what I haven't told you :)

I am doing a migration from phpbb to Zikula. The problem I am trying to use Files to solve is attachments to forum posts, and there are a few hundred of them. So I manually created a folder structure that matches what would be created for these users automatically if they had uploaded them themselves. But the Files code was not used, so no file name transformations have taken place. So if the files had spaces in the names, they are still there.

I didn't think that would matter because in my tests I didn't observe the file names being changed. Of course I didn't test it using a file with spaces in it. But my belief is that users shouldn't have to follow any particular rules about naming files here because they don't have to elsewhere. I could go and rename my manually migrated files, swapping _ for spaces, but the data linking to them would have to change as well and for several hundred files that would be a lot of work.

Hope this helps fill in the blanks. (I am not above bad puns)