Announcement

#1 2020-04-23 16:43:23

exogadget
Member
2020-04-20
8

Cyrillic and other unconventional letters in name of symlinked gallery

Hello/Hi/Greetings,

so friends, after few hours surfing the forum and google I see that Piwigo doesn't work with non-English letters in the file/folder names, am I right? I would much appreciate you if you correct my belief.

What is my problem exactly?
I have a lot of folders (and some files) on my NAS Synology (tested not only on Synology but on usual Windows folder) with Cyrillic letters in the names. I vote for English naming, but not only me use these folders. Rename all of them is not proper solution, better I'll find another soft.

These folders are symlinked (mount --bind) to "gallery" folder of Piwigo. When I try to sync them I've got the message:
"[./galleries/photoalbum/день_рожденья] PWG-UPDATE-1 (wrong filename)"

I tried to add this param to config.inc.php in /local/config/ but without success, the problem wasn't solved:
$conf['sync_chars_regex'] = '/^[[:alpha:][:digit:]-_.\sйцукенгшщзхїфівапролджєячсмитьбюЙЦУКЕНГШЩЗХЇФІВАПРОЛДЖЄЯЧСМИТЬБЮёЁъЪыЫэЭ!\(\)\&\/\°\'\,]+$/';

If I create Cyrillic album in Piwigo, of course, it works properly, as physically it isn't Cyrillic folder in structure, just a name in DB.

Do you know any solution?

Piwigo version: 2.10.2
PHP version: 7.3.11
MySQL version: 5.5.62-MariaDB
Piwigo URL: http://sorry it's closed for all

Offline

 

#2 2020-04-23 17:47:33

Zentalquabula
Member
2014-05-10
208

Re: Cyrillic and other unconventional letters in name of symlinked gallery

Operating system? What locale settings do you have? I assume Piwigo like all modern software requires UTF-8 in the file system.

Offline

 

#3 2020-04-24 11:27:53

exogadget
Member
2020-04-20
8

Re: Cyrillic and other unconventional letters in name of symlinked gallery

Zentalquabula wrote:

Operating system? What locale settings do you have? I assume Piwigo like all modern software requires UTF-8 in the file system.

Yes, there is UTF-8, all folders were created in Windows 10 and local is Ukrainian which is very similar to Russian.

Offline

 

#4 2020-04-24 13:20:19

erAck
Only trying to help
2015-09-06
1414

Re: Cyrillic and other unconventional letters in name of symlinked gallery

As $conf['sync_chars_regex'] is used with the PHP preg_match() function you may have to append the u modifier to make that work. Make sure the editor you use writes file content in UTF-8 encoding and that the web server process also runs in UTF-8 locale context. It might also unlikely be your PHP wasn't compiled with UTF-8 for PCRE, in that case prepend a (*UTF8) to the regex. You can also try to express the Cyrillic characters as Unicode code points, e.g. й would be \x{0439} and so on. Instead of listing each individually you can also use a range, e.g. \x{0439}-\x{044E} or whatever suits there.
See https://www.php.net/manual/en/function.preg-match.php


Running Piwigo at https://erack.net/gallery/

Offline

 

#5 2020-04-27 14:06:31

exogadget
Member
2020-04-20
8

Re: Cyrillic and other unconventional letters in name of symlinked gallery

These modifications didn't solve the issue.

setlocale(LC_ALL, 'ru_RU.UTF-8');
setlocale(LC_NUMERIC, 'C');
$conf['sync_chars_regex'] = '/^[[:alpha:][:digit:]-_.\s\x{0410}-\x{044F}\(\)\&\/\°\'\,]+$/';


I'm sorry, I'm not good in PHP, what did I do wrong?

Offline

 

#6 2020-04-28 00:30:32

erAck
Only trying to help
2015-09-06
1414

Re: Cyrillic and other unconventional letters in name of symlinked gallery

The actual Cyrillic script Unicode range is larger than just \x{0410}-\x{044F} so probably you're missing characters there. For example these characters of your previous expression are not in that range:
ЁЄІЇёєії
which are 0x401 0x404 0x406 0x407 0x451 0x454 0x456 0x457
There are several Cyrillic script blocks (i.e. also Supplement, Extended-A,-B,-C), you seem to use range U+0400 to U+045F of the block U+0400 to U+04FF, see https://r12a.github.io/uniview/?block=cyrillic

You can test your expression against single file names at https://regex101.com/ with the PCRE (PHP) flavor.

Btw, the \ backslash escape for the single characters \(\)\&\/\°\'\, is not needed in the character list, except for the / forward slash, it just makes the expression less readable. That could be  ()&°',\/  instead.


Running Piwigo at https://erack.net/gallery/

Offline

 

#7 2020-06-10 12:12:39

exogadget
Member
2020-04-20
8

Re: Cyrillic and other unconventional letters in name of symlinked gallery

erAck wrote:

The actual Cyrillic script Unicode range is larger than just \x{0410}-\x{044F} so probably you're missing characters there. For example these characters of your previous expression are not in that
...
Btw, the \ backslash escape for the single characters \(\)\&\/\°\'\, is not needed in the character list, except for the / forward slash, it just makes the expression less readable. That could be  ()&°',\/  instead.

Done! Thanks much, erAck!

But I did some additional steps:
1) set collation to utf8mb4_unicode_ci for DB;
2) config.inc.php was changed with:

setlocale(LC_ALL, 'ru_RU.UTF-8');
setlocale(LC_NUMERIC, 'C');
$conf['sync_chars_regex'] = '/^[[:alpha:][:digit:]\_.\s\x{0400}-\x{04FF}()&\/°\',!\-]+$/u';

'u' at the end, \- and \' were the stumbling stones.

Now everything works fine.

Offline

 

#8 2020-06-10 18:02:54

erAck
Only trying to help
2015-09-06
1414

Re: Cyrillic and other unconventional letters in name of symlinked gallery

Btw, you should remove the \' apostrophe, at least with directory names it does not work and may or may not (or only partially) work with file names, see [Forum, topic 30356] Directory Names with ' in.


Running Piwigo at https://erack.net/gallery/

Offline

 

#9 2020-06-10 20:01:38

exogadget
Member
2020-04-20
8

Re: Cyrillic and other unconventional letters in name of symlinked gallery

This sign is used in Ukrainian, e.g. Кам'яна, say frankly that isn't a real apostrophe, but thank for your help!
This char could be used in FS file naming.

Offline

 

#10 2020-06-10 23:01:36

erAck
Only trying to help
2015-09-06
1414

Re: Cyrillic and other unconventional letters in name of symlinked gallery

Nevertheless the character you used is
U+0027 ' APOSTROPHE
however the context might be in your language. The apostrophe does confuse some processing hence should not appear in the regex.


Running Piwigo at https://erack.net/gallery/

Offline

 

#11 2020-06-12 08:24:15

exogadget
Member
2020-04-20
8

Re: Cyrillic and other unconventional letters in name of symlinked gallery

You're right. It causes. Checked on filenames with \'. Excluded it from naming.

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact