Bläddra i källkod

Merge branch 'master' into outbound

* master:
  sca: fix private hold handling
  xhttp_pi: escape special characters
Peter Dunkley 12 år sedan
förälder
incheckning
44e43d541b
3 ändrade filer med 65 tillägg och 4 borttagningar
  1. 3 0
      modules/sca/sca_appearance.h
  2. 6 1
      modules/sca/sca_call_info.c
  3. 56 3
      modules/xhttp_pi/xhttp_pi_fnc.c

+ 3 - 0
modules/sca/sca_appearance.h

@@ -38,6 +38,9 @@ enum {
     SCA_APPEARANCE_STATE_HELD_PRIVATE,
     SCA_APPEARANCE_STATE_UNKNOWN = 0xff,
 }; 
+#define sca_appearance_is_held( app1 ) \
+	((app1) && ((app1)->state == SCA_APPEARANCE_STATE_HELD || \
+		   (app1)->state == SCA_APPEARANCE_STATE_HELD_PRIVATE))
 
 enum {
     SCA_APPEARANCE_FLAG_DEFAULT = 0,

+ 6 - 1
modules/sca/sca_call_info.c

@@ -982,6 +982,11 @@ sca_call_info_invite_request_handler( sip_msg_t *msg, sca_call_info *call_info,
 
     if ( sca_call_is_held( msg )) {
 	state = SCA_APPEARANCE_STATE_HELD;
+	if ( call_info->state == SCA_APPEARANCE_STATE_HELD_PRIVATE ) {
+	    state = SCA_APPEARANCE_STATE_HELD_PRIVATE;
+	} else {
+	    state = SCA_APPEARANCE_STATE_HELD;
+	}
     } else if ( !SCA_STR_EMPTY( &to->tag_value )) {
 	/* this is a reINVITE from an SCA line that put the call on hold */
 	state = SCA_APPEARANCE_STATE_ACTIVE;
@@ -1237,7 +1242,7 @@ sca_call_info_invite_reply_200_handler( sip_msg_t *msg,
 	goto done;
     }
 
-    if ( app->state != SCA_APPEARANCE_STATE_HELD ) {
+    if ( !sca_appearance_is_held( app )) {
 	state = SCA_APPEARANCE_STATE_ACTIVE;
     }
     /* if a Call-Info header is present, app-index goes to Contact */

+ 56 - 3
modules/xhttp_pi/xhttp_pi_fnc.c

@@ -243,6 +243,49 @@ do{								\
 }while(0)
 
 
+#define XHTTP_PI_ESC_COPY(p,str,temp_holder,temp_counter)	\
+do{	\
+	(temp_holder).s = (str).s;	\
+	(temp_holder).len = 0;	\
+	for((temp_counter)=0;(temp_counter)<(str).len;(temp_counter)++) {	\
+		switch((str).s[(temp_counter)]) {	\
+		case '<':	\
+			(temp_holder).len = (temp_counter) - (temp_holder).len;	\
+			XHTTP_PI_COPY_2(p, (temp_holder), XHTTP_PI_ESC_LT);	\
+			(temp_holder).s += (temp_counter) + 1;	\
+			(temp_holder).len = (temp_counter) + 1;	\
+			break;	\
+		case '>':	\
+			(temp_holder).len = (temp_counter) - (temp_holder).len;	\
+			XHTTP_PI_COPY_2(p, (temp_holder), XHTTP_PI_ESC_GT);	\
+			(temp_holder).s += (temp_counter) + 1;	\
+			(temp_holder).len = (temp_counter) + 1;	\
+			break;	\
+		case '&':	\
+			(temp_holder).len = (temp_counter) - (temp_holder).len;	\
+			XHTTP_PI_COPY_2(p, (temp_holder), XHTTP_PI_ESC_AMP);	\
+			(temp_holder).s += (temp_counter) + 1;	\
+			(temp_holder).len = (temp_counter) + 1;	\
+			break;	\
+		case '"':	\
+			(temp_holder).len = (temp_counter) - (temp_holder).len;	\
+			XHTTP_PI_COPY_2(p, (temp_holder), XHTTP_PI_ESC_QUOT);	\
+			(temp_holder).s += (temp_counter) + 1;	\
+			(temp_holder).len = (temp_counter) + 1;	\
+			break;	\
+		case '\'':	\
+			(temp_holder).len = (temp_counter) - (temp_holder).len;	\
+			XHTTP_PI_COPY_2(p, (temp_holder), XHTTP_PI_ESC_SQUOT);	\
+			(temp_holder).s += (temp_counter) + 1;	\
+			(temp_holder).len = (temp_counter) + 1;	\
+			break;	\
+		}	\
+	}	\
+	(temp_holder).len = (temp_counter) - (temp_holder).len;	\
+	XHTTP_PI_COPY(p, (temp_holder));	\
+}while(0)
+
+
 static const str XHTTP_PI_Response_Head_1 = str_init("<html><head><title>"\
 	"Kamailio Provisionning Interface</title>"\
 	"<style type=\"text/css\">"\
@@ -349,6 +392,12 @@ static const str XHTTP_PI_Response_Foot = str_init(\
 #define XHTTP_PI_ROWSPAN 20
 static const str XHTTP_PI_CMD_ROWSPAN = str_init("20");
 
+static const str XHTTP_PI_ESC_LT =    str_init("&lt;");   /* < */
+static const str XHTTP_PI_ESC_GT =    str_init("&gt;");   /* > */
+static const str XHTTP_PI_ESC_AMP =   str_init("&amp;");  /* & */
+static const str XHTTP_PI_ESC_QUOT =  str_init("&quot;"); /* " */
+static const str XHTTP_PI_ESC_SQUOT = str_init("&#39;");  /* ' */
+
 
 xmlAttrPtr ph_xmlNodeGetAttrByName(xmlNodePtr node, const char *name)
 {
@@ -2543,7 +2592,8 @@ int ph_run_pi_cmd(pi_ctx_t* ctx)
 	str arg_url = {ctx->arg.s, ctx->arg.len};
 	str arg_name;
 	str arg_val;
-	//unsigned long i;
+	str temp_holder;
+	int temp_counter;
 	int i;
 	int j;
 	int max_page_len = ctx->reply.buf.len;
@@ -2733,8 +2783,11 @@ int ph_run_pi_cmd(pi_ctx_t* ctx)
 							values[j].val.str_val.len,
 							values[j].val.str_val.s,
 							val_str.len, val_str.s);
-					XHTTP_PI_COPY(p,
-						val_str.len?val_str:XHTTP_PI_NBSP);
+						if (val_str.len) {
+							XHTTP_PI_ESC_COPY(p, val_str, temp_holder, temp_counter);
+						} else {
+							XHTTP_PI_COPY(p, XHTTP_PI_NBSP);
+						}
 						break;
 					case DB1_INT:
 						val_str.s = p;