From 26492c4260e764de5f8c804e03dc7560593e96b8 Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 16 Jun 2022 15:04:49 +0200 Subject: [PATCH] fix for US numbers formatted as "+1 123-456-7890" --- api/src/Contacts.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/src/Contacts.php b/api/src/Contacts.php index d149ad3a2d..1a284beea3 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -2835,9 +2835,10 @@ class Contacts extends Contacts\Storage } if ($only_keys === true) $only_keys = false; $start = false; // no pagination - list($country, $area, $rest) = explode(' ', + // returns "+49 123 4567890" or "+1 123-456-7890" + list($country, $area, $rest) = preg_split('/[ -]/', $phoneNumberUtil->format($number, \libphonenumber\PhoneNumberFormat::INTERNATIONAL), 3); - $rest_without_space = str_replace(' ', '', $rest); + $rest_without_space = preg_replace('/[^0-9]/', '', $rest); /** @var Contacts\Sql */ $backend = $this->get_backend(null, $filter['owner']); // SQL Backend supporting regexp_replace (MySQL 8.0+ or MariaDB 10.0+ or PostgreSQL)