Parcourir la source

siputils: reintroduced the c function for is_alphanum()

- accidentaly stripped when adding is_alphanumex()
- reported by Carsten Bock
Daniel-Constantin Mierla il y a 8 ans
Parent
commit
2d0a0d8dec

+ 28 - 1
src/modules/siputils/checks.c

@@ -807,11 +807,38 @@ int is_numeric(sip_msg_t *msg, char *_sp, char* _s2)
 	return 1;
 }
 
+
+/*
+ * Check if the parameter contains alphanumeric characters
+ */
+int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2)
+{
+	str tval = {0, 0};
+	int i;
+
+	if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
+		LM_ERR("cannot get parameter value\n");
+		return -1;
+	}
+	if(tval.len<=0)
+		return -2;
+
+	i = 0;
+	for(; i<tval.len; i++) {
+	if( !((tval.s[i]>='0' && tval.s[i]<='9')
+			|| (tval.s[i]>='A' && tval.s[i]<='Z')
+			|| (tval.s[i]>='z' && tval.s[i]<='z')) )
+		return -3;
+	}
+
+	return 1;
+}
+
 /*
  * Check if the parameter contains alphanumeric characters or are part of
  * the second parameter
  */
-int is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
+int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
 {
 	str tval = {0, 0};
 	str eset = {0, 0};

+ 2 - 2
src/modules/siputils/checks.h

@@ -127,12 +127,12 @@ int is_numeric(sip_msg_t *msg, char *_sp, char* _s2);
 /*
  * Check if the parameter contains alphanumeric characters
  */
-int is_alphanum(sip_msg_t *msg, char *_sp, char* _s2);
+int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2);
 
 /*
  * Check if the parameter contains alphanumeric characters or are part of
  * the second parameter
  */
-int is_alphanumex(sip_msg_t *msg, char *_sp, char* _se);
+int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se);
 
 #endif /* CHECKS_H */

+ 2 - 2
src/modules/siputils/siputils.c

@@ -179,9 +179,9 @@ static cmd_export_t cmds[]={
 		0, ANY_ROUTE},
 	{"is_numeric", (cmd_function)is_numeric,                 1, fixup_spve_null,
 		0, ANY_ROUTE},
-	{"is_alphanum", (cmd_function)is_alphanum,               1, fixup_spve_null,
+	{"is_alphanum", (cmd_function)ksr_is_alphanum,               1, fixup_spve_null,
 		0, ANY_ROUTE},
-	{"is_alphanumex", (cmd_function)is_alphanumex,           2, fixup_spve_spve,
+	{"is_alphanumex", (cmd_function)ksr_is_alphanumex,           2, fixup_spve_spve,
 		0, ANY_ROUTE},
 	{"sip_p_charging_vector", (cmd_function)sip_handle_pcv,  1, fixup_spve_null,
 		fixup_free_spve_null, ANY_ROUTE},