Skip to content

fix(commands): Improve phone number input validation of OCC commands#17173

Draft
nickvergessen wants to merge 2 commits intomainfrom
bugfix/noid/improve-phonenumber-validation
Draft

fix(commands): Improve phone number input validation of OCC commands#17173
nickvergessen wants to merge 2 commits intomainfrom
bugfix/noid/improve-phonenumber-validation

Conversation

@nickvergessen
Copy link
Member

@nickvergessen nickvergessen commented Feb 19, 2026

β˜‘οΈ Resolves

πŸ› οΈ API Checklist

🚧 Tasks

  • Add a setupcheck:
    grafik

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not possible
  • πŸ“˜ API documentation in docs/ has been updated or is not required
  • πŸ”– Capability is added or not needed

@nickvergessen nickvergessen self-assigned this Feb 19, 2026
@nickvergessen nickvergessen added feature: api πŸ› οΈ OCS API for conversations, chats and participants feature: SFU & SIP ☎️ labels Feb 19, 2026
@nickvergessen nickvergessen marked this pull request as draft February 19, 2026 23:00
// And matches a local number or dial-through
&& preg_match('/^[0-9]{1,20}$/', $phoneNumber)
) {
return $phoneNumber;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@nickvergessen nickvergessen force-pushed the bugfix/noid/improve-phonenumber-validation branch from ba6e346 to 9111c65 Compare March 6, 2026 09:23
@nickvergessen nickvergessen requested a review from fancycode March 6, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: api πŸ› οΈ OCS API for conversations, chats and participants feature: SFU & SIP ☎️

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants