Announcement

#1 2024-05-06 16:07:21

wiedaar
Member
2024-05-06
1

Adding characters to $conf['sync_chars_regex']

Hello

I want to add some characters but i have no idea how to, if i ad a character i got a lot of errors or it doesnt do anything.
i want to add the folowing characters : '+- &()
there is a space in between
and there may be some more characters that wil show op later when i sync

so if anyone can help me, thank you!

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

the database is in utf8mb4_unicode_ci

There have been a lot of questions about this in the last 10 years and in all the answers i couldnt find a solution.


Piwigo 14.4.0 Upgradecontrole
Geïnstalleerd op 6 mei 2024, 1 uur in de toekomst
Besturingssysteem: WINNT
PHP: 8.2.18 (Toon info) [2024-05-06 13:57:11]
MySQL: 8.3.0 [2024-05-06 15:57:11]
Afbeeldingen-bibliotheek: GD bundled (2.1.0 compatible)
Cache grootte Niet beschikbaar   nooit berekend Ververs

Offline

 

#2 2024-05-06 19:27:50

erAck
Only trying to help
2015-09-06
2091

Re: Adding characters to $conf['sync_chars_regex']

First, you can not add the U+0027 ' APOSTROPHE character, neither as literal nor escaped.
Second, it is not a good idea to add the U+0026 & AMPERSAND character; while it may work in many contexts it may fail in some.
Please read the documentation comments in include/config_default.inc.php (the read-only default config) for $conf['sync_chars_regex'], starting at line 865 with

// Permitted characters for files/directories during synchronization.

or just here linked in the source repository https://github.com/Piwigo/Piwigo/blob/d … c.php#L865

As the statement contains a regular expression, care has to be taken that the U+002D - HYPHEN-MINUS character has a special meaning within a set expression ([], character classes) in that it denotes a range of characters between its immediate left and right bounds unless it immediately follows a range, it should best be listed as first character.

So, if you omit the ' and & characters from your list, the resulting expression statement in the local/config/config.inc.php file would be

Code:

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

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

Offline

 

Board footer

Powered by FluxBB

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