Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
5cf68816
Commit
5cf68816
authored
Dec 02, 2020
by
Sylvain Berfini
🐮
Browse files
Unescape characters if possible in linphone_core_interpret_url()
parent
7079e79c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
22 deletions
+37
-22
coreapi/linphonecore.c
coreapi/linphonecore.c
+6
-4
coreapi/proxy.c
coreapi/proxy.c
+31
-18
No files found.
coreapi/linphonecore.c
View file @
5cf68816
...
...
@@ -3977,17 +3977,19 @@ void linphone_core_iterate(LinphoneCore *lc){
}
}
LinphoneAddress
*
linphone_core_interpret_url
(
LinphoneCore
*
lc
,
const
char
*
url
){
LinphoneAddress
*
linphone_core_interpret_url
(
LinphoneCore
*
lc
,
const
char
*
url
)
{
if
(
!
url
)
return
NULL
;
LinphoneProxyConfig
*
proxy
=
linphone_core_get_default_proxy_config
(
lc
);
LinphoneAddress
*
result
=
NULL
;
LinphoneAddress
*
result
=
NULL
;
if
(
linphone_proxy_config_
is
_phone_number
(
proxy
,
url
)
)
{
char
*
normalized_number
=
linphone_proxy_config_
normalize
_phone
_number
(
proxy
,
url
);
char
*
normalized_number
=
linphone_proxy_config_
normalize
_phone_number
(
proxy
,
url
)
;
if
(
normalize
d
_number
)
{
result
=
linphone_proxy_config_normalize_sip_uri
(
proxy
,
normalized_number
);
ms_free
(
normalized_number
);
}
else
{
result
=
linphone_proxy_config_normalize_sip_uri
(
proxy
,
url
);
}
return
result
;
}
...
...
coreapi/proxy.c
View file @
5cf68816
...
...
@@ -701,37 +701,47 @@ const char *linphone_proxy_config_get_quality_reporting_collector(const Linphone
bool_t
linphone_proxy_config_is_phone_number
(
LinphoneProxyConfig
*
proxy
,
const
char
*
username
){
const
char
*
p
;
if
(
!
username
)
return
FALSE
;
for
(
p
=
username
;
*
p
!=
'\0'
;
++
p
){
const
char
*
p
;
char
*
unescaped_username
=
belle_sip_username_unescape_unnecessary_characters
(
username
);
for
(
p
=
unescaped_username
;
*
p
!=
'\0'
;
++
p
)
{
if
(
isdigit
(
*
p
)
||
*
p
==
' '
||
*
p
==
'.'
||
*
p
==
'-'
||
*
p
==
')'
||
*
p
==
'('
||
*
p
==
'/'
||
*
p
==
'+'
||
(
unsigned
char
)
*
p
==
0xca
||
(
unsigned
char
)
*
p
==
0xc2
||
(
unsigned
char
)
*
p
==
0xa0
// non-breakable space (iOS uses it to format contacts phone number)
)
{
*
p
==
' '
||
*
p
==
'.'
||
*
p
==
'-'
||
*
p
==
')'
||
*
p
==
'('
||
*
p
==
'/'
||
*
p
==
'+'
||
// non-breakable space (iOS uses it to format contacts phone number)
(
unsigned
char
)
*
p
==
0xca
||
(
unsigned
char
)
*
p
==
0xc2
||
(
unsigned
char
)
*
p
==
0xa0
)
{
continue
;
}
belle_sip_free
(
unescaped_username
);
return
FALSE
;
}
belle_sip_free
(
unescaped_username
);
return
TRUE
;
}
//remove anything but [0-9] and +
static
char
*
linphone_proxy_config_flatten_phone_number
(
LinphoneProxyConfig
*
proxy
,
const
char
*
number
)
{
char
*
result
=
reinterpret_cast
<
char
*>
(
ms_malloc0
(
strlen
(
number
)
+
1
));
char
*
w
=
result
;
char
*
unescaped_phone_number
=
belle_sip_username_unescape_unnecessary_characters
(
number
);
char
*
result
=
reinterpret_cast
<
char
*>
(
ms_malloc0
(
strlen
(
unescaped_phone_number
)
+
1
));
char
*
w
=
result
;
const
char
*
r
;
for
(
r
=
number
;
*
r
!=
'\0'
;
++
r
){
if
(
*
r
==
'+'
||
isdigit
(
*
r
)){
*
w
++=*
r
;
for
(
r
=
unescaped_phone_number
;
*
r
!=
'\0'
;
++
r
)
{
if
(
*
r
==
'+'
||
isdigit
(
*
r
))
{
*
w
++
=
*
r
;
}
}
*
w
++=
'\0'
;
*
w
++
=
'\0'
;
belle_sip_free
(
unescaped_phone_number
);
return
result
;
}
...
...
@@ -876,7 +886,10 @@ LinphoneAddress* linphone_proxy_config_normalize_sip_uri(LinphoneProxyConfig *pr
}
else
{
linphone_address_clean
(
uri
);
linphone_address_set_display_name
(
uri
,
NULL
);
linphone_address_set_username
(
uri
,
username
);
// Unescape character if possible
char
*
unescaped_username
=
belle_sip_username_unescape_unnecessary_characters
(
username
);
linphone_address_set_username
(
uri
,
unescaped_username
);
belle_sip_free
(
unescaped_username
);
return
_linphone_core_destroy_addr_if_not_sip
(
uri
);
}
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment