Skip to content

Commit

Permalink
modules/rls: normalize RLS entry URIs
Browse files Browse the repository at this point in the history
- RLS entry URI is xs:AnyURI, which may be an absolute or relative URI.
  In relative URI, URI scheme is missing.

(cherry picked from commit 68bb6b3)
(cherry picked from commit 41a211e)
  • Loading branch information
juha-h authored and miconda committed Jul 29, 2015
1 parent 5996db0 commit d7164b0
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions modules/rls/subscribe.c
Expand Up @@ -987,23 +987,32 @@ int send_resource_subs(char* uri, void* param)
str pres_uri, *tmp_str;
struct sip_uri parsed_pres_uri;
int duplicate = 0;
str *normalized_uri;

subs_info_t *s = (subs_info_t *) ((void**)param)[0];
list_entry_t **rls_contact_list = (list_entry_t **) ((void**)param)[1];

pres_uri.s = uri;
pres_uri.len = strlen(uri);
if (parse_uri(pres_uri.s, pres_uri.len, &parsed_pres_uri) < 0)
{
LM_ERR("bad uri: %.*s\n", pres_uri.len, pres_uri.s);
return -1;

normalized_uri = normalize_sip_uri(&pres_uri);
if (normalized_uri->s == NULL || normalized_uri->len == 0) {
LM_ERR("failed to normalize RLS entry URI %.*s\n",
pres_uri.len, pres_uri.s);
return -1;
}

if (parse_uri(normalized_uri->s, normalized_uri->len, &parsed_pres_uri)
< 0) {
LM_ERR("bad uri: %.*s\n", normalized_uri->len, normalized_uri->s);
return -1;
}

if (check_self(&parsed_pres_uri.host, 0, PROTO_NONE) != 1
&& rls_disable_remote_presence != 0)
{
LM_WARN("Unable to subscribe to remote contact %.*s for watcher %.*s\n",
pres_uri.len, pres_uri.s,
normalized_uri->len, normalized_uri->s,
s->watcher_uri->len,
s->watcher_uri->s);
return 1;
Expand All @@ -1014,8 +1023,8 @@ int send_resource_subs(char* uri, void* param)
if (rls_max_backend_subs > 0 && ++counter > rls_max_backend_subs)
return 1;

s->pres_uri = &pres_uri;
s->remote_target = &pres_uri;
s->pres_uri = normalized_uri;
s->remote_target = normalized_uri;

/* Build list of contacts... checking each contact exists only once */
if ((tmp_str = (str *)pkg_malloc(sizeof(str))) == NULL)
Expand All @@ -1029,8 +1038,8 @@ int send_resource_subs(char* uri, void* param)
LM_ERR("out of private memory\n");
return -1;
}
memcpy(tmp_str->s, pres_uri.s, pres_uri.len);
tmp_str->len = pres_uri.len;
memcpy(tmp_str->s, normalized_uri->s, normalized_uri->len);
tmp_str->len = normalized_uri->len;
*rls_contact_list = list_insert(tmp_str, *rls_contact_list, &duplicate);
if (duplicate != 0)
{
Expand Down

0 comments on commit d7164b0

Please sign in to comment.