[synchronization] Normalize UTF-8 filenames before synchronization #323

Open
opened 2026-10-04 23:52:07 +02:00 by adam · 3 comments
Owner

Reported by mindhaq on 9 Apr 2015 14:51

Version: 2.7.4

Filenames scanned during synchronization should be UTF-8 normalized to the precomposed format using Normalizer. At least when default encoding is utf-8 and PHP 5.3 is available.

http://us2.php.net/manual/en/class.normalizer.php

Additional information: UTF-8 allows two different ways to encode umlaut special characters like the german ä, ü, ä. For technical background on that see e.g. the following:

http://stackoverflow.com/questions/1089966/utf8-filenames-in-php-and-different-unicode-encodings

I upload images from my Mac to my Linux server via SSH, and some of them contain Umlaut characters. For those files to be imported, I already changed the regex to the following:

$conf['sync_chars_regex'] = '/^[\s,.'\pL0-9-_.]+$/u';

Which works fine for files with Umlaut I create directly on the server.

On the Mac, the Umlauts ä are encoded in the decomposed format 0x61cc88. When I upload them, they keep that filename. This is no problem for Linux, the names are displayed just fine. However, PHPs regex parser does not match those decomposed characters with the \pL character group (which it should). So it would be great if those filenames would be normalized before matching.

Piwigo Bugtracker #3218

**Reported by mindhaq on 9 Apr 2015 14:51** **Version:** 2.7.4 Filenames scanned during synchronization should be UTF-8 normalized to the precomposed format using Normalizer. At least when default encoding is utf-8 and PHP 5.3 is available. http://us2.php.net/manual/en/class.normalizer.php **Additional information:** UTF-8 allows two different ways to encode umlaut special characters like the german ä, ü, ä. For technical background on that see e.g. the following: http://stackoverflow.com/questions/1089966/utf8-filenames-in-php-and-different-unicode-encodings I upload images from my Mac to my Linux server via SSH, and some of them contain Umlaut characters. For those files to be imported, I already changed the regex to the following: $conf[&#039;sync_chars_regex&#039;] = &#039;/^[\s,.&#039;\pL0-9-_.]+$/u&#039;; Which works fine for files with Umlaut I create directly on the server. On the Mac, the Umlauts ä are encoded in the decomposed format 0x61cc88. When I upload them, they keep that filename. This is no problem for Linux, the names are displayed just fine. However, PHPs regex parser does not match those decomposed characters with the \pL character group (which it should). So it would be great if those filenames would be normalized before matching. [Piwigo Bugtracker #3218](http://piwigo.org/bugs/view.php?id=3218) <!-- github-sync-id:97252345 -->
Author
Owner

Is it possible to move $conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_.]+$/'; line to configuration file from admin/site_update.php:763? Or at least use some variable from config file?
After each piwigo update I must add my own regex over and over again because this files is always overwritten.

Is it possible to move $conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_.]+$/'; line to configuration file from admin/site_update.php:763? Or at least use some variable from config file? After each piwigo update I must add my own regex over and over again because this files is always overwritten. <!-- github-comment-id:224675357 -->
Author
Owner
@fri-K Did you read http://piwigo.org/doc/doku.php?id=user_documentation:use:features:conf_locale ? <!-- github-comment-id:224675894 -->
Author
Owner

@flop25 It looks like it should work, I'll see on next update. Thanks for the tip :)

@flop25 It looks like it should work, I'll see on next update. Thanks for the tip :) <!-- github-comment-id:224910447 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#323