Project

General

Profile

Actions

Bug #5632

closed

Javascript SyntaxError: Nothing to repeat: in regexp for phone numbers validation

Added by beat over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
High
Assignee:
Target version:
Start date:
03 December 2015
Due date:
% Done:

100%

Estimated time:

Description

This needs confirmation:

Saving a profile with a phone number gives:
Javascript SyntaxError: Nothing to repeat and fails validation without error message.

Pattern is:

"^([0-9](|-)?)?(\(?[0-9]{3}\)?|[0-9]{3})(|-)?([0-9]{3}(+|-)?[0-9]{4}|[a-zA-Z0-9]{7})$"

where

(+|-)?

has no backslash to escape the +

The string "+|-" can be found at various places unescaped.

correct string should be (and it does not allow area-codes in the form of (021) 123 123 123:

/^([0-9](\+|-)?)?(\(?[0-9]{3}\)?|[0-9]{3})(\+|-)?([0-9]{3}(\+|-)?[0-9]{4}|[a-zA-Z0-9]{7})$/

Additionally I saw on a site the + replaced by http-encoded spaces as follows:

/^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$/

In the field edit form (but once saved with the backslash-pluses it worked.


Related issues 1 (0 open1 closed)

Related to CB - Bug #5641: Multiple words with spaces validation breaks user manager save buttonsClosedkrileon08 December 2015

Actions
Actions #1

Updated by beat over 8 years ago

We could also validate regexps on save of field settings (try-catch in php the regexp)

Actions #2

Updated by krileon over 8 years ago

This also needs confirmation based off browser. Could be an out of date browser issue causing buggy escaping (Chrome did this in a previous validation bug investigated).

Actions #3

Updated by nant about 8 years ago

Update:

All 3 patters

seems to be ok with FF and Safari on a Mac with latest nightly build.

Actions #4

Updated by nant about 8 years ago

  • Assignee changed from nant to beat
Actions #5

Updated by krileon about 8 years ago

Appears fixed by MR !996

Actions #6

Updated by krileon about 8 years ago

  • Related to Bug #5641: Multiple words with spaces validation breaks user manager save buttons added
Actions #7

Updated by krileon about 8 years ago

  • Status changed from New to Resolved
  • Assignee changed from beat to krileon
  • % Done changed from 0 to 100
Actions #8

Updated by beat about 8 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF