Bug #5632
closedJavascript SyntaxError: Nothing to repeat: in regexp for phone numbers validation
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.
Updated by beat about 9 years ago
We could also validate regexps on save of field settings (try-catch in php the regexp)
Updated by krileon about 9 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).
Updated by nant almost 9 years ago
Update:
All 3 patters
seems to be ok with FF and Safari on a Mac with latest nightly build.
Updated by krileon almost 9 years ago
- Related to Bug #5641: Multiple words with spaces validation breaks user manager save buttons added
Updated by krileon almost 9 years ago
- Status changed from New to Resolved
- Assignee changed from beat to krileon
- % Done changed from 0 to 100