mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-08 19:08:14 +00:00
Issue #6450 - Don't remove characters from SIP uri's when not needed
Patch by jcomellas, heavily modified by oej git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
37
callerid.c
37
callerid.c
@@ -905,19 +905,40 @@ void ast_shrink_phone_number(char *n)
|
|||||||
n[y] = '\0';
|
n[y] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*! \brief Checks if phone number consists of valid characters
|
||||||
|
\param exten String that needs to be checked
|
||||||
|
\param valid Valid characters in string
|
||||||
|
\return 1 if valid string, 0 if string contains invalid characters
|
||||||
|
*/
|
||||||
|
static int ast_is_valid_string(const char *exten, const char *valid)
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
|
||||||
|
if (ast_strlen_zero(exten))
|
||||||
|
return 0;
|
||||||
|
for (x=0; exten[x]; x++)
|
||||||
|
if (!strchr(valid, exten[x]))
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*! \brief checks if string consists only of digits and * \# and +
|
/*! \brief checks if string consists only of digits and * \# and +
|
||||||
\return 1 if string is valid AST phone number
|
\return 1 if string is valid AST phone number
|
||||||
\return 0 if not
|
\return 0 if not
|
||||||
*/
|
*/
|
||||||
int ast_isphonenumber(char *n)
|
int ast_isphonenumber(const char *n)
|
||||||
{
|
{
|
||||||
int x;
|
return ast_is_valid_string(n, "0123456789*#+");
|
||||||
if (ast_strlen_zero(n))
|
}
|
||||||
return 0;
|
|
||||||
for (x=0;n[x];x++)
|
/*! \brief checks if string consists only of digits and ( ) - * \# and +
|
||||||
if (!strchr("0123456789*#+", n[x]))
|
Pre-qualifies the string for ast_shrink_phone_number()
|
||||||
return 0;
|
\return 1 if string is valid AST shrinkable phone number
|
||||||
return 1;
|
\return 0 if not
|
||||||
|
*/
|
||||||
|
int ast_is_shrinkable_phonenumber(const char *exten)
|
||||||
|
{
|
||||||
|
return ast_is_valid_string(exten, "0123456789*#+()-.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief parse string for caller id information
|
/*! \brief parse string for caller id information
|
||||||
|
|||||||
@@ -7234,7 +7234,8 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
|
|||||||
*c = '\0';
|
*c = '\0';
|
||||||
tmp = ast_strdupa(of);
|
tmp = ast_strdupa(of);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ast_shrink_phone_number(tmp);
|
if (ast_is_shrinkable_phonenumber(tmp))
|
||||||
|
ast_shrink_phone_number(tmp);
|
||||||
ast_string_field_set(p, cid_num, tmp);
|
ast_string_field_set(p, cid_num, tmp);
|
||||||
} else {
|
} else {
|
||||||
ast_string_field_set(p, cid_num, of);
|
ast_string_field_set(p, cid_num, of);
|
||||||
@@ -7265,7 +7266,8 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
|
|||||||
ast_string_field_set(p, cid_name, calleridname);
|
ast_string_field_set(p, cid_name, calleridname);
|
||||||
tmp = ast_strdupa(rpid_num);
|
tmp = ast_strdupa(rpid_num);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ast_shrink_phone_number(tmp);
|
if (ast_is_shrinkable_phonenumber(tmp))
|
||||||
|
ast_shrink_phone_number(tmp);
|
||||||
ast_string_field_set(p, cid_num, tmp);
|
ast_string_field_set(p, cid_num, tmp);
|
||||||
} else {
|
} else {
|
||||||
ast_string_field_set(p, cid_num, rpid_num);
|
ast_string_field_set(p, cid_num, rpid_num);
|
||||||
@@ -7301,7 +7303,8 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
|
|||||||
if (!ast_strlen_zero(user->cid_num) && !ast_strlen_zero(p->cid_num)) {
|
if (!ast_strlen_zero(user->cid_num) && !ast_strlen_zero(p->cid_num)) {
|
||||||
char *tmp = ast_strdupa(user->cid_num);
|
char *tmp = ast_strdupa(user->cid_num);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ast_shrink_phone_number(tmp);
|
if (ast_is_shrinkable_phonenumber(tmp))
|
||||||
|
ast_shrink_phone_number(tmp);
|
||||||
ast_string_field_set(p, cid_num, tmp);
|
ast_string_field_set(p, cid_num, tmp);
|
||||||
} else {
|
} else {
|
||||||
ast_string_field_set(p, cid_num, user->cid_num);
|
ast_string_field_set(p, cid_num, user->cid_num);
|
||||||
@@ -7376,7 +7379,8 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
|
|||||||
if (*calleridname)
|
if (*calleridname)
|
||||||
ast_string_field_set(p, cid_name, calleridname);
|
ast_string_field_set(p, cid_name, calleridname);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ast_shrink_phone_number(tmp);
|
if (ast_is_shrinkable_phonenumber(tmp))
|
||||||
|
ast_shrink_phone_number(tmp);
|
||||||
ast_string_field_set(p, cid_num, tmp);
|
ast_string_field_set(p, cid_num, tmp);
|
||||||
} else {
|
} else {
|
||||||
ast_string_field_set(p, cid_num, rpid_num);
|
ast_string_field_set(p, cid_num, rpid_num);
|
||||||
@@ -7430,7 +7434,8 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
|
|||||||
if (!ast_strlen_zero(peer->cid_num) && !ast_strlen_zero(p->cid_num)) {
|
if (!ast_strlen_zero(peer->cid_num) && !ast_strlen_zero(p->cid_num)) {
|
||||||
char *tmp = ast_strdupa(peer->cid_num);
|
char *tmp = ast_strdupa(peer->cid_num);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ast_shrink_phone_number(tmp);
|
if (ast_is_shrinkable_phonenumber(tmp))
|
||||||
|
ast_shrink_phone_number(tmp);
|
||||||
ast_string_field_set(p, cid_num, tmp);
|
ast_string_field_set(p, cid_num, tmp);
|
||||||
} else {
|
} else {
|
||||||
ast_string_field_set(p, cid_num, peer->cid_num);
|
ast_string_field_set(p, cid_num, peer->cid_num);
|
||||||
|
|||||||
@@ -193,11 +193,18 @@ extern int ast_gen_cas(unsigned char *outbuf, int sas, int len, int codec);
|
|||||||
*/
|
*/
|
||||||
extern void ast_shrink_phone_number(char *n);
|
extern void ast_shrink_phone_number(char *n);
|
||||||
|
|
||||||
/*! \brief Check if a string consists only of digits.
|
/*! \brief Check if a string consists only of digits and + \#
|
||||||
\param n number to be checked.
|
\param n number to be checked.
|
||||||
\return Returns 0 if n is a number, 1 if it's not.
|
\return Returns 0 if n is a number, 1 if it's not.
|
||||||
*/
|
*/
|
||||||
extern int ast_isphonenumber(char *n);
|
extern int ast_isphonenumber(const char *n);
|
||||||
|
|
||||||
|
/*! \brief Check if a string consists only of digits and and + \# ( ) - .
|
||||||
|
(meaning it can be cleaned with ast_shrink_phone_number)
|
||||||
|
\param exten The extension (or URI) to be checked.
|
||||||
|
\return Returns 0 if n is a number, 1 if it's not.
|
||||||
|
*/
|
||||||
|
extern int ast_is_shrinkable_phonenumber(const char *exten);
|
||||||
|
|
||||||
extern int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen);
|
extern int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user