noxxi / p5-net-sip

Net::SIP Perl Module
Other
15 stars 22 forks source link

Feature request: Please add helper functions for composing and parsing SIP name-addr #27

Closed pali closed 4 years ago

pali commented 4 years ago

Net::SIP::Util already provides sip_uri2parts helper function which can parse addr-spec or name-addr and extract from it domain, user, $proto and other uri parameters. But it does not extract nor return display-name from, which is the only additional part in name-addr when comparing with plain addr-spec.

For SIP applications display-name is useful as it contain string which can be displayed to user. So it would be nice if some Net::SIP provides generic helper functions for constructing SIP name-addr from values domain, display-name, user, proto, params and also reverse function which returns these values from SIP name-addr string (like sip_uri2parts, but with also display-name).

noxxi commented 4 years ago

I don't think this is trivial to get fully correct, with all the escaping, multi-byte encoding (UTF-8), handling both quoted and unquoted etc. And even if being correct it might not match what others implement, so it might be necessary to add work-arounds too. Given that there is currently no use for this kind of functionality in Net::SIP itself I better stay away from this now.

pali commented 3 years ago

I don't think this is trivial to get fully correct

I know. And I thought that this could be reason why main Net::SIP module should provide such function, so other projects do not have to implement it... and because it is non-trivial they may implement it incorrectly and invent a new incompatible implementation.

Given that there is currently no use for this kind of functionality in Net::SIP itself

I think that in Net::SIP source code there are some places where is this splitting used via regex (and maybe also incorrectly...).