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 2 commits intomainfrom
Conversation
| // 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.
There was a problem hiding this comment.
So the only thing I can do is look for a leading 0 or +
try to convert to standard and strip of the +, if there was no + return it's invalid?
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
ba6e346 to
9111c65
Compare
βοΈ Resolves
π οΈ API Checklist
π§ Tasks
π Checklist
docs/has been updated or is not required