Announcement

#1 2020-03-09 16:46:51

jokerigno
Member
2020-03-09
3

Apos in sync_chars_regex

Hi all,

I just installed Piwigo in my unraid server and tried to import photos.

I have issue with sync tool because a lot of my photos has an apos in the folder or file name (very common in italian language).

There's a way to allow sync_chars_regex to manage apos "  '  " ?

Thank you in advance

Piwigo version: 2.10.1 installed via linuxserver docker container.

Offline

 

#2 2020-03-09 20:47:47

executive
Member
2017-08-16
1214

Re: Apos in sync_chars_regex

From "How To Add Pictures" in the documentation:

https://piwigo.org/doc/doku.php?id=user … ure#by_ftp

Offline

 

#3 2020-03-09 21:25:02

jokerigno
Member
2020-03-09
3

Re: Apos in sync_chars_regex

So the anwser is simply "no"?

Because I already found a way to add special characters like "é". I was wondering if there is a similar solution for " ' ".

Offline

 

#4 2020-03-10 11:33:10

erAck
Only trying to help
2015-09-06
2023

Re: Apos in sync_chars_regex

Why is the answer no? If you already know how it's done then the trick is how to get the escaping the quote right. It might be \'


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

Offline

 

#5 2020-03-10 18:24:54

executive
Member
2017-08-16
1214

Re: Apos in sync_chars_regex

I didn't say no. I provided you a link because the solution is there. Did you try adding apostrophe to the regular expression as the instructions indicate?

Offline

 

#6 2020-03-10 22:17:47

jokerigno
Member
2020-03-09
3

Re: Apos in sync_chars_regex

Sorry maybe I'm stupid but where are the istructions?

In the text you provided me I read:

"File name and album limitations: the name of directories and files must contain only letters, numbers, ”-”, “_” or ”.”. No blank spaces, nor accentuated characters."

and then

"The list of characters allowed can be extended using the config var: $conf['sync_chars_regex'] and its default value is '/^[a-zA-Z0-9-_.]+$/'."

But no info on HOW to extend it.

I tried using this config but I receive error:

'[A-z\s\d][\\'\"\\^\&\+\\-\°\#\!\?\@]'

Offline

 

#7 2020-03-11 01:48:45

erAck
Only trying to help
2015-09-06
2023

Re: Apos in sync_chars_regex

The value for sync_chars_regex must be a regular expression which your attempt is not.
In the default regex within the [] character class the a-z means all small ASCII letter, A-Z all capital ASCII letters, 0-9 all ASCII digits plus the three characters hyphen, underscore and dot.

Now this '[A-z\s\d][\\'\"\\^\&\+\\-\°\#\!\?\@]' probably wouldn't match any of your file names even if it was a valid expression because already A-z does not what you think it would do. It is not a range from capital letter A to small letter z because the codepoint order is different, small letters are before capital letters. It's not like in your phone book, hence the original expression uses separate sets within the class. Furthermore you defined an expression with two character classes [A-z..] and [\\...] that both would have to match two consecutive characters of your file name. But overall the \\ is one escaped backslash and the following ' ends the PHP string already and the rest remains as garbage. Because you said "I already found a way to add special characters like "é"" I thought you would know, but apparently you didn't. So, keep the original expression intact but just add the desired characters to the one character class, but you will have to backslash-escape an apostrophe that otherwise would end the string. Probably something like this:

$conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_.\']+$/'

Now if the list should include the characters you gave in your try it's probably

Code:

$conf['sync_chars_regex'] = '/^[a-zA-Z0-9-_.\'"^&+°#!?@]+$/'

You can test expressions (the part between the leading '/ and the trailing /') against sample file names at https://regex101.com/ like this specific example one saved as https://regex101.com/r/TmugD3/1/


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

Offline

 

#8 2020-03-11 02:07:18

erAck
Only trying to help
2015-09-06
2023

Re: Apos in sync_chars_regex

Note however that sync_chars_regex is also used to determine category names from directory names, which may look pretty ugly if all those ^&+°#!?@ are included. Furthermore I don't know what might happen if characters that might have a meta character meaning in expressions or PHP/SQL context are present in name values.


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

Offline

 

#9 2021-03-06 11:03:03

TOnin
Member
1970-01-01
106

Re: Apos in sync_chars_regex

Hi,
Like said, including apos ' in your file names and allowing them would break Piwigo SQL queries.
More information on code side: [synchronization] Sync fail with files containing ' (apostrophe) in filename
[Github] Piwigo issue #250

On filename side, you may find a nice solution replacing it ' with ’ Unicode prefered one (U+2019)

Code:

' replaced by ’ (which is not `)

Wikipedia wrote:

This is the preferred character to use for apostrophe according to the Unicode standard.[110][111]
https://en.wikipedia.org/wiki/Apostrophe#Unicode

Offline

 

Board footer

Powered by FluxBB

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