Overview
Comment: | Fix issues with french apostrophes in user search |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
79a2d31f0d7fbdd6767ddfd887591b61 |
User & Date: | bohwaz on 2022-03-05 00:28:44 |
Other Links: | manifest | tags |
Context
2022-03-07
| ||
02:15 | Add page to show balance of all accounts check-in: bbd12328fb user: bohwaz tags: trunk | |
2022-03-05
| ||
00:28 | Fix issues with french apostrophes in user search check-in: 79a2d31f0d user: bohwaz tags: trunk | |
00:28 | Don't prevent paste events all the time check-in: 22664e354e user: bohwaz tags: trunk | |
Changes
Modified src/include/lib/Garradin/DB.php from [f9346ac0ca] to [0e139875a3].
︙ | ︙ | |||
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | * This is probably not the best way to do that, but we have to resort to that * as ICU extension is rarely available. * * @see https://www.sqlite.org/c3ref/strlike.html * @see https://sqlite.org/src/file?name=ext/icu/icu.c&ci=trunk */ static public function unicodeLike($pattern, $value, $escape = null) { $id = md5($pattern . $escape); if (!array_key_exists($id, self::$unicode_patterns_cache)) { $escape = $escape ? '(?!' . preg_quote($escape, '/') . ')' : ''; preg_match_all('/('.$escape.'[%_])|(\pL+)|(.+?)/iu', $pattern, $parts, PREG_SET_ORDER); $pattern = ''; foreach ($parts as $part) { if (isset($part[3])) { $pattern .= preg_quote(strtolower($part[0]), '/'); } elseif (isset($part[2])) { | > > > | | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | * This is probably not the best way to do that, but we have to resort to that * as ICU extension is rarely available. * * @see https://www.sqlite.org/c3ref/strlike.html * @see https://sqlite.org/src/file?name=ext/icu/icu.c&ci=trunk */ static public function unicodeLike($pattern, $value, $escape = null) { $pattern = str_replace('’', '\'', $pattern); // Normalize French apostrophe $value = str_replace('’', '\'', $value); $id = md5($pattern . $escape); if (!array_key_exists($id, self::$unicode_patterns_cache)) { $escape = $escape ? '(?!' . preg_quote($escape, '/') . ')' : ''; preg_match_all('/('.$escape.'[%_])|(\pL+)|(.+?)/iu', $pattern, $parts, PREG_SET_ORDER); $pattern = ''; foreach ($parts as $part) { if (isset($part[3])) { $pattern .= preg_quote(strtolower($part[0]), '/'); } elseif (isset($part[2])) { $pattern .= preg_quote(Utils::unicodeCaseFold($part[2]), '/'); } elseif ($part[1] == '%') { $pattern .= '.*'; } elseif ($part[1] == '_') { $pattern .= '.'; } |
︙ | ︙ |
Modified src/include/lib/Garradin/Template.php from [35e3b3eed2] to [70c0807438].
︙ | ︙ | |||
759 760 761 762 763 764 765 | // Fix for autocomplete, lpignore is for Lastpass $attributes .= 'autocomplete="off" data-lpignore="true" '; if (!empty($params['user_mode']) && empty($config->editable)) { $out = '<dt>' . htmlspecialchars($config->title, ENT_QUOTES, 'UTF-8') . '</dt>'; | | | 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 | // Fix for autocomplete, lpignore is for Lastpass $attributes .= 'autocomplete="off" data-lpignore="true" '; if (!empty($params['user_mode']) && empty($config->editable)) { $out = '<dt>' . htmlspecialchars($config->title, ENT_QUOTES, 'UTF-8') . '</dt>'; $out .= '<dd>' . (trim((string) $value) === '' ? 'Non renseigné' : $this->displayChampMembre($value, $config)) . '</dd>'; return $out; } if ($type == 'select') { $field .= '<select '.$attributes.'>'; foreach ($options as $k=>$v) |
︙ | ︙ |
Modified src/include/lib/Garradin/Utils.php from [43bc722d18] to [134e773c3a].
︙ | ︙ | |||
982 983 984 985 986 987 988 989 990 991 992 993 994 995 | * @see https://www.matthecat.com/supprimer-les-accents-d-une-chaine-avec-php.html */ static public function unicodeCaseFold(?string $str): string { if (null === $str || trim($str) === '') { return ''; } if (!isset(self::$transliterator) && function_exists('transliterator_create')) { self::$transliterator = \Transliterator::create('Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; Lower();'); } if (isset(self::$transliterator)) { return self::$transliterator->transliterate($str); | > > | 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | * @see https://www.matthecat.com/supprimer-les-accents-d-une-chaine-avec-php.html */ static public function unicodeCaseFold(?string $str): string { if (null === $str || trim($str) === '') { return ''; } $str = str_replace('’', '\'', $str); // Normalize French apostrophe if (!isset(self::$transliterator) && function_exists('transliterator_create')) { self::$transliterator = \Transliterator::create('Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; Lower();'); } if (isset(self::$transliterator)) { return self::$transliterator->transliterate($str); |
︙ | ︙ |