-
-
Notifications
You must be signed in to change notification settings - Fork 213
file-naming / autorenaming issues in the file-manager #8295
Comments
|
What would be an appropriate way to confirm this? |
|
I can confirm the first post in 3.5.9 on Windows 10. Server Linux Apache 2.0 Handler. |
|
Test on 3.5.9 on Lubuntu 15.10, en_US.utf8, Apache 2.4 with LANG=C, PHP mbstring, client Window 7 Firefox/IE11: The database If I correct the name in the database and reload the file manager page, the initial umlaut is dropped from the display again. Also, any attempt to edit the name in the filemanager edit page fails, the database entry remains unchanged (the manually inserted leading umlaut is kept). Selecting the file in a download element results in a wrong filename display and a successful download with a wrong filename - also for a name manually corrected in the database. |
|
One more test:
|
|
i wonder what @fenepedia did... |
|
Hmm I think @leofeyer could answer this question better than me. My Server ist hosted and configured by him. |
|
@contao/developers /cc |
|
For one test case, download (see my prior comment), I drilled the issue down to a problem with the PHP You can easily verify it by inserting into It can also be reproduced on the command line: A hot fix in /**
* TEMP.FIX for pathinfo() locale C issue
*/
private static function mypathinfo($strPath)
{
$oldlocale = setlocale(LC_CTYPE, "0");
setlocale(LC_CTYPE, 'en_US.utf8');
$arr = pathinfo($strPath);
setlocale(LC_CTYPE, oldlocale);
return $arr;
}
/**
* Return an object property
...
*/
public function __get($strKey)
{
switch ($strKey)
{
...
case 'name':
case 'basename':
if (!isset($this->arrPathinfo[$strKey]))
{
==> $this->arrPathinfo = static::mypathinfo(TL_ROOT . '/' . $this->strFile);
}
return $this->arrPathinfo['basename'];
break;This rough fix also covers the file upload case (in database, not in filemanager display).. |
|
As a brute-force approach, just inserting setlocale(LC_CTYPE, 'en_US.utf8');into |
|
Seems we have to use a library or copy the http://core.wp-a2z.org/oik_api/phpmailermb_pathinfo/ Or here: http://stackoverflow.com/a/34619682 |
|
http://php.net/manual/en/function.pathinfo.php says (RTFM helps once more):
So it seems that locale switching is the right way (it is already used in some vendor code). In my tests, setting LC_CTYPE was sufficient (and probably less overhead than LC_ALL), and only the charset (utf8) should be relevant (using en_US as safest language code). A solution without changing core code is redefining namespace Contao;
function pathinfo($path, $option=null)
{
$locale = setlocale(LC_CTYPE, '0');
setlocale(LC_CTYPE, 'en_US.utf8');
$result = is_null($option) ? \pathinfo($path) : \pathinfo($path, $option);
setlocale(LC_CTYPE, $locale);
return $result;
}
function basename($path, $suffix=null)
{
$locale = setlocale(LC_CTYPE, '0');
setlocale(LC_CTYPE, 'en_US.utf8');
$result = \basename($path, $suffix);
setlocale(LC_CTYPE, $locale);
return $result;
}Namespaces are made for such things... |
|
👍 sounds promising... |
|
Using
|
|
I second @aschempp's concerns, therefore I'd prefer to add a |
|
Sounds like it should rather go to |
|
Also, this seems to be a very common problem. There are over 38,000 code snippets when searching for mb_pathinfo on Github: https://github.com/search?q=mb_pathinfo&type=Code&utf8=%E2%9C%93 |
### 4.1.3 (2016-04-22) * Use data URIs for the image preview in the back end. * Use DIRECTORY_SEPARATOR to convert kernel.cache_dir into a relative path (see #464). * Always trigger the "isVisibleElement" hook (see contao/core#8312). * Do not change all sessions when switching users (see contao/core#8158). * Do not allow to close fieldsets with empty required fields (see contao/core#8300). * Make the path related properties of the File class binary-safe (see contao/core#8295). * Correctly validate and decode IDNA e-mail addresses (see contao/core#8306). * Skip forward pages entirely in the book navigation module (see contao/core#5074). * Do not add the X-Priority header in the Email class (see contao/core#8298). * Determine the search index checksum in a more reliable way (see contao/core#7652).
? |
|
How exactly do I reproduce the issue? |
|
I encountered the following under Windows: If I put a file called When I do a dabfs sync afterwards, it will say When I then upload another file named exactly the same ( This is the state of the database afterwards: |
|
I can reproduce @asaage 's problem under Linux: If I put a file called When I do a Dbafs sync afterwards, it will say When I edit the file, it will display the name normally: If you rename the file to |
|
I cannot reproduce the issue on Mac OS X, which is why I'm struggling to fix it. Anyone else? @contao/developers /cc |
|
The problem with Windows is the following: http://stackoverflow.com/questions/15055192/why-does-windows-need-to-utf8-decode-filenames-for-file-get-contents-to-work It's quite a bitch ;). I stumbled upon this in an extension of mine, but I could never solve it directly (in my case the file paths are now |
|
the db entry btw i'm on Linux. i did not check how that behaves if i put the file via ftp and sync afterwards. |
|
I was able to reproduce the issue on Linux, however I'm not sure what to do now. In contrast to the initial problem description, I did not have a problem renaming the file in Contao 3.5.25. |
|
Renaming as well as displaying the first character is working flawlessly since at least 3.5.17. |
|
Since we are removing those rules in Contao 4.4 entirely (see contao/core-bundle@0c0b3d8), I'm closing the issue. |

















the 3.5.8 Version (and probably older versions too) strip the first charakter of the filename on upload in case of äöü..
it's not reproduceable in the online-demo due to fileupload resrictions.
following szenario:
sourc-file
Änderungsantrag.pdfdestination-file (upload in contao 3.3.3) becomes
Aenderungsantrag.pdfand shows up asAenderungsantrag.pdfcompared to 3.5.8 where the behavior differs and seems to be a little messed up.
sourc-file
Änderungsantrag.pdfdestination-file (upload in contao 3.5.8) will be saved as
Änderungsantrag.pdfbut shows up as
nderungsantrag.pdf+ renaming this file is now impossible.still 3.5.8:
uploading
Büro.pngwill be saved asBüro.pngand shows up asBüro.png👍but renaming it to
Büro_foo.pngresults inBuero_foo.pngi would consider this as 3 bugs
(i personaly would like to be able to use every character that has no special meaning to the underlying sytem / file-system like linux/windows)
The text was updated successfully, but these errors were encountered: