[sr-dev] git:sr_3.0: core: parse_to display name multi-token no-quotes fix

Andrei Pelinescu-Onciul andrei at iptel.org
Thu Mar 4 10:25:54 CET 2010


Module: sip-router
Branch: sr_3.0
Commit: 731ff13d8dd72cd4610715cb4c4c1322746ab263
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=731ff13d8dd72cd4610715cb4c4c1322746ab263

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Wed Mar  3 19:24:08 2010 +0100

core: parse_to display name multi-token no-quotes fix

Fix for properly returning a non-quoted display name that is
composed of several tokens (contains spaces). The previous version
would set the display name to the first token, in this case
(e.g. Foo Bar <sip:foo at bar> resulted in display_name="Foo" instead
 of "Foo Bar").

Reported-by: Ronald Voermans  ronald voermans nu
Closes FlySpray#39 .
(cherry picked from commit 907686c0c4c1141af175d692251b8e1fab28b64e)

---

 parser/parse_to.c |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/parser/parse_to.c b/parser/parse_to.c
index a8f3883..30ac170 100644
--- a/parser/parse_to.c
+++ b/parser/parse_to.c
@@ -27,8 +27,13 @@
  * History:
  * ---------
  * 2003-04-26 ZSW (jiri)
+ * 2010-03-03  fix multi-token no-quotes display name (andrei)
  */
 
+/** Parser :: Parse To: header.
+ * @file
+ * @ingroup parser
+ */
 
 #include "parse_to.h"
 #include <stdlib.h>
@@ -41,7 +46,7 @@
 
 enum {
 	START_TO, DISPLAY_QUOTED, E_DISPLAY_QUOTED, DISPLAY_TOKEN,
-	S_URI_ENCLOSED, URI_ENCLOSED, E_URI_ENCLOSED,
+	DISPLAY_TOKEN_SP, S_URI_ENCLOSED, URI_ENCLOSED, E_URI_ENCLOSED,
 	URI_OR_TOKEN, MAYBE_URI_END, END, F_CR, F_LF, F_CRLF
 };
 
@@ -532,6 +537,10 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 	to_b->uri.s= 0;
 	to_b->display.len = 0;
 	to_b->display.s = 0;
+	to_b->tag_value.len = 0;
+	to_b->tag_value.s = 0;
+	to_b->param_lst = 0;
+	to_b->last_param = 0;
 	foo=0;
 
 	for( tmp=buffer; tmp<end; tmp++)
@@ -556,6 +565,10 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						foo = tmp;
 						status = MAYBE_URI_END;
 						break;
+					case DISPLAY_TOKEN:
+						foo = tmp;
+						status = DISPLAY_TOKEN_SP;
+						break;
 				}
 				break;
 			case '\n':
@@ -565,12 +578,17 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						foo = tmp;
 						status = MAYBE_URI_END;
 					case MAYBE_URI_END:
-					case DISPLAY_TOKEN:
+					case DISPLAY_TOKEN_SP:
 					case E_DISPLAY_QUOTED:
 					case END:
 						saved_status=status;
 						status=F_LF;
 						break;
+					case DISPLAY_TOKEN:
+						foo=tmp;
+						saved_status=DISPLAY_TOKEN_SP;
+						status=F_LF;
+						break;
 					case F_CR:
 						status=F_CRLF;
 						break;
@@ -592,12 +610,17 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						foo = tmp;
 						status = MAYBE_URI_END;
 					case MAYBE_URI_END:
-					case DISPLAY_TOKEN:
+					case DISPLAY_TOKEN_SP:
 					case E_DISPLAY_QUOTED:
 					case END:
 						saved_status=status;
 						status=F_CR;
 						break;
+					case DISPLAY_TOKEN:
+						foo=tmp;
+						saved_status=DISPLAY_TOKEN_SP;
+						status=F_CR;
+						break;
 					case F_CRLF:
 					case F_CR:
 					case F_LF:
@@ -652,10 +675,13 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						status = S_URI_ENCLOSED;
 						break;
 					case URI_OR_TOKEN:
-					case DISPLAY_TOKEN: 
+					case DISPLAY_TOKEN:
+						to_b->display.len=tmp-to_b->display.s;
+						status = S_URI_ENCLOSED;
+						break;
+					case DISPLAY_TOKEN_SP:
 					case MAYBE_URI_END:
-						/* deal with the incorrect displayname<uri>.. */
-						to_b->display.len=(foo?foo:tmp)-to_b->display.s;
+						to_b->display.len=foo-to_b->display.s;
 						status = S_URI_ENCLOSED;
 						break;
 					case F_CRLF:
@@ -756,6 +782,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						status=URI_ENCLOSED;
 						break;
 					case MAYBE_URI_END:
+					case DISPLAY_TOKEN_SP:
 						status = DISPLAY_TOKEN;
 					case DISPLAY_QUOTED:
 					case DISPLAY_TOKEN:




More information about the sr-dev mailing list