fix(commands): Improve phone number input validation of OCC commands#17173
fix(commands): Improve phone number input validation of OCC commands#17173nickvergessen wants to merge 3 commits intomainfrom
Conversation
Signed-off-by: Joas Schilling <coding@schilljs.com>
| // And matches a local number or dial-through | ||
| && preg_match('/^[0-9]{1,20}$/', $phoneNumber) | ||
| ) { | ||
| return $phoneNumber; |
There was a problem hiding this comment.
@fancycode is the free pass for local numbers okay? Or should e.g. 0711 be replaced with 49711 if DE is specified as default phone prefix. I assume it would be bad, as it would prevent specifying 0711… even if that would be what your SIP gate receives
There was a problem hiding this comment.
An internal extension should never start with a 0, so you could add the international prefix if configured (i.e. 071112345 becomes +4971112345) or just reject such numbers.
To make things worse, the 00 prefix for international numbers is only if calling from Germany to another country. For example calling from the US to another country needs 011 as prefix, from Australia it's 0011. See https://en.wikipedia.org/wiki/List_of_international_call_prefixes for other prefixes. So replacing 00 with a + will fail for Australian people trying to configure 00114971112345 as German number in Stuttgart.
You could try to guess based on the default phone prefix what the user might try to do, but maybe the easiest is to simply reject numbers that start with a 0.
Signed-off-by: Joas Schilling <coding@schilljs.com>
☑️ Resolves
🛠️ API Checklist
🚧 Tasks
🏁 Checklist
docs/has been updated or is not required