[sr-dev] git:master: dialplan: don't print PV name in replacement

Daniel-Constantin Mierla miconda at gmail.com
Sat Dec 18 00:35:55 CET 2010


Module: sip-router
Branch: master
Commit: eb005b74c1d47d215b17ac395efafe56c14ec295
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=eb005b74c1d47d215b17ac395efafe56c14ec295

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sat Dec 18 00:34:54 2010 +0100

dialplan: don't print PV name in replacement

- reported by Andreas Granig

---

 modules/dialplan/dp_repl.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/dialplan/dp_repl.c b/modules/dialplan/dp_repl.c
index 5831f36..2b8454c 100644
--- a/modules/dialplan/dp_repl.c
+++ b/modules/dialplan/dp_repl.c
@@ -123,6 +123,8 @@ int rule_translate(struct sip_msg *msg, str string, dpl_node_t * rule,
 	pv_value_t sv;
 	str* uri;
 	int ovector[3 * (MAX_REPLACE_WITH + 1)];
+	char *p;
+	int size;
 
 	dp_output_buf[0] = '\0';
 	result->s = dp_output_buf;
@@ -180,6 +182,7 @@ int rule_translate(struct sip_msg *msg, str string, dpl_node_t * rule,
 
 	/* offset- offset in the replacement string */
 	result->len = repl_nb = offset = 0;
+	p=repl_comp->replacement.s;
 	
 	while( repl_nb < repl_comp->n_escapes){
 		token = repl_comp->replace[repl_nb];
@@ -191,9 +194,11 @@ int rule_translate(struct sip_msg *msg, str string, dpl_node_t * rule,
 				goto error;
 			}
 			/*copy from the replacing string*/
-			memcpy(result->s + result->len, repl_comp->replacement.s + offset,
-				token.offset-offset);
-			result->len += (token.offset - offset);
+			size=repl_comp->replacement.s+repl_comp->replace[repl_nb].offset-p;
+			memcpy(result->s + result->len, p, size);
+			result->len += size;
+			p+=size+repl_comp->replace[repl_nb].size;
+
 			offset += token.offset-offset; /*update the offset*/
 		}
 
@@ -261,10 +266,9 @@ int rule_translate(struct sip_msg *msg, str string, dpl_node_t * rule,
 	/* anything left? */
 	if( repl_nb && token.offset+token.size < repl_comp->replacement.len){
 		/*copy from the replacing string*/
-		memcpy(result->s + result->len,
-			repl_comp->replacement.s + token.offset+token.size, 
-			repl_comp->replacement.len -(token.offset+token.size) );
-			result->len +=repl_comp->replacement.len-(token.offset+token.size);
+		size = repl_comp->replacement.s+repl_comp->replacement.len-p;
+		memcpy(result->s + result->len, p, size);
+		result->len += size;
 	}
 
 	result->s[result->len] = '\0';




More information about the sr-dev mailing list