Author Topic: Is not a valid phone number  (Read 1037 times)

Offline sky writer

  • Posts: 926
Is not a valid phone number
« on: January 21, 2016, 06:43:54 AM »
Bakery ver 1.76 does not accept 555-555-5555 as a valid phone number.  This is standard North American formatting.

I notice there is a new forward slash added to the preg_match code on ~line 139 of save_form.php
if (!preg_match('#^[0-9)(xX +.-/]{7,20}$#', $value)) {
Code: [Select]
if (!preg_match('#^[0-9)(xX +.-/]{7,20}$#', $value)) {
The slash was not present in bakery ver 1.72 save_form.php
Code: [Select]
if (!preg_match('#^[0-9)(xX +.-]{7,20}$#', $value)) {This accepts 555-555-5555 formatting.

Is there an intended purpose for the added slash?


  • Guest
Re: Is not a valid phone number
« Reply #1 on: January 21, 2016, 11:40:44 AM »
Hi sky writer

It is a bug. Hyphens (-) inside of a regexp character class definition should be escaped else they are used as a meta-character.
The forward slash was added to the pattern in v1.7.6 to comply with some European phone number formats, eg. 089 / 123 45 67.

save_form.php about line 139:
Code: [Select]
if (!preg_match('#^[0-9)(xX +./\-]{7,20}$#', $value)) {
Thanks for the hint! I will fix it in all regexp patterns of the address form validation.

Regards Christoph