Module: sip-router
Branch: master
Commit: 251c0218e7d5e09f43a2b834a5450c20bb4f6d60
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=251c021…
Author: Vicente Hernando <vhernando(a)systemonenoc.com>
Committer: Vicente Hernando <vhernando(a)systemonenoc.com>
Date: Thu May 16 12:06:55 2013 +0200
modules/uac: avoid adding double quotes in uac_replace_* functions
- updated uac doc with a note and examples.
---
modules/uac/doc/uac_admin.xml | 14 +++++++++-
modules/uac/uac.c | 50 +---------------------------------------
2 files changed, 14 insertions(+), 50 deletions(-)
diff --git a/modules/uac/doc/uac_admin.xml b/modules/uac/doc/uac_admin.xml
index 3610f12..05dc713 100644
--- a/modules/uac/doc/uac_admin.xml
+++ b/modules/uac/doc/uac_admin.xml
@@ -484,6 +484,10 @@ modparam("uac", "reg_contact_addr",
"192.168.1.2:5080")
<para>
This function can be used from REQUEST_ROUTE and from BRANCH_ROUTE.
</para>
+ <para>NOTE: Previous versions of this function added double quotes automatically
to
+ display variable. That is no longer the case, if you expect that behavior, you will
+ have to add the quotes by yourself.
+ </para>
<para>
If you set restore_mode to AUTO, the URI will be modified automatically in
all subsequent requests and replies in that dialog.
@@ -512,7 +516,8 @@ modparam("uac", "reg_contact_addr",
"192.168.1.2:5080")
# replace both display and uri
uac_replace_from("$avp(s:display)","$avp(s:uri)");
# replace only display and do not touch uri
-uac_replace_from("batman","");
+uac_replace_from("batman",""); # display is replaced with: batman
+uac_replace_from("\"batman\"",""); # display is replaced
with: "batman"
# remove display and replace uri
uac_replace_from("","sip:robin@gotham.org");
# remove display and do not touch uri
@@ -580,6 +585,10 @@ uac_restore_from();
<para>
This function can be used from REQUEST_ROUTE and from BRANCH_ROUTE.
</para>
+ <para>NOTE: Previous versions of this function added double quotes automatically
to
+ display variable. That is no longer the case, if you expect that behavior, you will
+ have to add the quotes by yourself.
+ </para>
<example>
<title><function>uac_replace_to</function> usage</title>
<programlisting format="linespecific">
@@ -587,7 +596,8 @@ uac_restore_from();
# replace both display and uri
uac_replace_to("$avp(display)","$avp(uri)");
# replace only display and do not touch uri
-uac_replace_to("batman","");
+uac_replace_to("batman",""); # display is replaced with: batman
+uac_replace_to("\"batman\"",""); # display is replaced
with: "batman"
# remove display and replace uri
uac_replace_to("","sip:robin@gotham.org");
# remove display and do not touch uri
diff --git a/modules/uac/uac.c b/modules/uac/uac.c
index a7cd414..5142e03 100644
--- a/modules/uac/uac.c
+++ b/modules/uac/uac.c
@@ -98,7 +98,6 @@ static int w_uac_auth(struct sip_msg* msg, char* str, char* str2);
static int w_uac_reg_lookup(struct sip_msg* msg, char* src, char* dst);
static int w_uac_reg_request_to(struct sip_msg* msg, char* src, char* mode_s);
static int fixup_replace_uri(void** param, int param_no);
-static int fixup_replace_disp_uri(void** param, int param_no);
static int mod_init(void);
static void mod_destroy(void);
static int child_init(int rank);
@@ -114,13 +113,13 @@ static pv_export_t mod_pvs[] = {
/* Exported functions */
static cmd_export_t cmds[]={
- {"uac_replace_from", (cmd_function)w_replace_from, 2,
fixup_replace_disp_uri, 0,
+ {"uac_replace_from", (cmd_function)w_replace_from, 2, fixup_replace_uri, 0,
REQUEST_ROUTE | BRANCH_ROUTE },
{"uac_replace_from", (cmd_function)w_replace_from, 1, fixup_replace_uri, 0,
REQUEST_ROUTE | BRANCH_ROUTE },
{"uac_restore_from", (cmd_function)w_restore_from, 0, 0,
0,
REQUEST_ROUTE },
- {"uac_replace_to", (cmd_function)w_replace_to, 2, fixup_replace_disp_uri,
0,
+ {"uac_replace_to", (cmd_function)w_replace_to, 2, fixup_replace_uri, 0,
REQUEST_ROUTE | BRANCH_ROUTE },
{"uac_replace_to", (cmd_function)w_replace_to, 1, fixup_replace_uri, 0,
REQUEST_ROUTE | BRANCH_ROUTE },
@@ -415,51 +414,6 @@ static int fixup_replace_uri(void** param, int param_no)
return 0;
}
-
-static int fixup_replace_disp_uri(void** param, int param_no)
-{
- pv_elem_t *model;
- char *p;
- str s;
-
- /* convert to str */
- s.s = (char*)*param;
- s.len = strlen(s.s);
-
- model=NULL;
- if (param_no==1)
- {
- if (s.len)
- {
- /* put " around display name */
- p = (char*)pkg_malloc(s.len+3);
- if (p==0)
- {
- LM_CRIT("no more pkg mem\n");
- return E_OUT_OF_MEM;
- }
- p[0] = '\"';
- memcpy(p+1, s.s, s.len);
- p[s.len+1] = '\"';
- p[s.len+2] = '\0';
- pkg_free(s.s);
- s.s = p;
- s.len += 2;
- }
- }
- if(pv_parse_format(&s ,&model)<0)
- {
- LM_ERR("wrong format [%s] for param no %d!\n", s.s, param_no);
- pkg_free(s.s);
- return E_UNSPEC;
- }
- *param = (void*)model;
-
- return 0;
-}
-
-
-
/************************** wrapper functions ******************************/
static int w_restore_from(struct sip_msg *msg)