From b3a1f678f8740a4628bb2cf2ff388c08868c2392 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 25 Nov 2014 17:56:40 +0100 Subject: [PATCH] =?utf8?q?SL::CTI::sanitize=5Fnumber:=20nur=20Ziffern=20zu?= =?utf8?q?r=C3=BCckliefern?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/CTI.pm | 3 ++- t/cti/call_link.t | 8 ++++---- t/cti/sanitize_number.t | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/SL/CTI.pm b/SL/CTI.pm index 8605ff163..3bc13860e 100644 --- a/SL/CTI.pm +++ b/SL/CTI.pm @@ -40,9 +40,10 @@ sub sanitize_number { my $idp = $config->{international_dialing_prefix} // '00'; my $number = $params{number} // ''; - $number =~ s/[^0-9+\.-]//g; # delete unsupported characters + $number =~ s/[^0-9+]//g; # delete unsupported characters my $countrycode = $number =~ s/^(?: $idp | \+ ) ( \d{2} )//x ? $1 : ''; # TODO: countrycodes can have more or less than 2 digits $number =~ s/^0//x if $countrycode; # kill non standard optional zero after global identifier + $number =~ s{[^0-9]+}{}g; return '' unless $number; diff --git a/t/cti/call_link.t b/t/cti/call_link.t index ce762399b..994a34856 100644 --- a/t/cti/call_link.t +++ b/t/cti/call_link.t @@ -12,11 +12,11 @@ use_ok 'SL::CTI'; } is SL::CTI->call_link(number => '0371 5347 620'), 'controller.pl?action=CTI/call&number=03715347620'; -is SL::CTI->call_link(number => '0049(0)421-22232 22'), 'controller.pl?action=CTI/call&number=0049421-2223222'; -is SL::CTI->call_link(number => '+49(0)421-22232 22'), 'controller.pl?action=CTI/call&number=0049421-2223222'; +is SL::CTI->call_link(number => '0049(0)421-22232 22'), 'controller.pl?action=CTI/call&number=00494212223222'; +is SL::CTI->call_link(number => '+49(0)421-22232 22'), 'controller.pl?action=CTI/call&number=00494212223222'; is SL::CTI->call_link(number => 'Tel: +49 40 809064 0'), 'controller.pl?action=CTI/call&number=0049408090640'; is SL::CTI->call_link(number => '0371 5347 620', internal => 1), 'controller.pl?action=CTI/call&number=03715347620&internal=1'; -is SL::CTI->call_link(number => '0049(0)421-22232 22', internal => 1), 'controller.pl?action=CTI/call&number=0049421-2223222&internal=1'; -is SL::CTI->call_link(number => '+49(0)421-22232 22', internal => 1), 'controller.pl?action=CTI/call&number=0049421-2223222&internal=1'; +is SL::CTI->call_link(number => '0049(0)421-22232 22', internal => 1), 'controller.pl?action=CTI/call&number=00494212223222&internal=1'; +is SL::CTI->call_link(number => '+49(0)421-22232 22', internal => 1), 'controller.pl?action=CTI/call&number=00494212223222&internal=1'; is SL::CTI->call_link(number => 'Tel: +49 40 809064 0', internal => 1), 'controller.pl?action=CTI/call&number=0049408090640&internal=1'; diff --git a/t/cti/sanitize_number.t b/t/cti/sanitize_number.t index 639e7167b..c39aa9a1f 100644 --- a/t/cti/sanitize_number.t +++ b/t/cti/sanitize_number.t @@ -12,6 +12,6 @@ use_ok 'SL::CTI'; } is SL::CTI->sanitize_number(number => '0371 5347 620'), '03715347620'; -is SL::CTI->sanitize_number(number => '0049(0)421-22232 22'), '0049421-2223222'; -is SL::CTI->sanitize_number(number => '+49(0)421-22232 22'), '0049421-2223222'; +is SL::CTI->sanitize_number(number => '0049(0)421-22232 22'), '00494212223222'; +is SL::CTI->sanitize_number(number => '+49(0)421-22232 22'), '00494212223222'; is SL::CTI->sanitize_number(number => 'Tel: +49 40 809064 0'), '0049408090640'; -- 2.20.1