Browse code

core: added global parameter hdr_name_extra_chars

- allow specifying additional chars to be allowed in header names

Daniel-Constantin Mierla authored on 23/07/2020 06:51:30
Showing 6 changed files
... ...
@@ -474,6 +474,7 @@ LATENCY_LIMIT_ACTION	latency_limit_action
474 474
 LATENCY_LIMIT_CFG		latency_limit_cfg
475 475
 
476 476
 URI_HOST_EXTRA_CHARS	"uri_host_extra_chars"
477
+HDR_NAME_EXTRA_CHARS	"hdr_name_extra_chars"
477 478
 
478 479
 MSG_TIME	msg_time
479 480
 ONSEND_RT_REPLY		"onsend_route_reply"
... ...
@@ -989,6 +990,7 @@ IMPORTFILE      "import_file"
989 990
 <INITIAL>{MODPARAM}     { count(); yylval.strval=yytext; return MODPARAM; }
990 991
 <INITIAL>{CFGENGINE}	{ count(); yylval.strval=yytext; return CFGENGINE; }
991 992
 <INITIAL>{URI_HOST_EXTRA_CHARS}	{ yylval.strval=yytext; return URI_HOST_EXTRA_CHARS; }
993
+<INITIAL>{HDR_NAME_EXTRA_CHARS}	{ yylval.strval=yytext; return HDR_NAME_EXTRA_CHARS; }
992 994
 
993 995
 <INITIAL>{EQUAL}	{ count(); return EQUAL; }
994 996
 <INITIAL>{ADDEQ}          { count(); return ADDEQ; }
... ...
@@ -507,6 +507,7 @@ extern char *default_routename;
507 507
 %token MSG_TIME
508 508
 %token ONSEND_RT_REPLY
509 509
 %token URI_HOST_EXTRA_CHARS
510
+%token HDR_NAME_EXTRA_CHARS
510 511
 
511 512
 %token FLAGS_DECL
512 513
 %token AVPFLAGS_DECL
... ...
@@ -1447,6 +1448,8 @@ assign_stm:
1447 1448
 	| USER_AGENT_HEADER EQUAL error { yyerror("string value expected"); }
1448 1449
 	| URI_HOST_EXTRA_CHARS EQUAL STRING { _sr_uri_host_extra_chars=$3; }
1449 1450
 	| URI_HOST_EXTRA_CHARS EQUAL error { yyerror("string value expected"); }
1451
+	| HDR_NAME_EXTRA_CHARS EQUAL STRING { _ksr_hname_extra_chars=$3; }
1452
+	| HDR_NAME_EXTRA_CHARS EQUAL error { yyerror("string value expected"); }
1450 1453
 	| REPLY_TO_VIA EQUAL NUMBER { reply_to_via=$3; }
1451 1454
 	| REPLY_TO_VIA EQUAL error { yyerror("boolean value expected"); }
1452 1455
 	| LISTEN EQUAL id_lst {
... ...
@@ -216,6 +216,7 @@ extern str _ksr_xavp_via_params;
216 216
 extern str _ksr_xavp_via_fields;
217 217
 
218 218
 extern char *_sr_uri_host_extra_chars;
219
+extern char *_ksr_hname_extra_chars;
219 220
 
220 221
 extern char *ksr_stats_namesep;
221 222
 
... ...
@@ -156,6 +156,11 @@ static ksr_hdr_map_idx_t _ksr_hdr_map_idx[KSR_HDR_MAP_IDX_SIZE];
156 156
  */
157 157
 static char *_ksr_hname_chars_list = "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._+~";
158 158
 
159
+/**
160
+ * additional valid chars in header names (core param)
161
+ */
162
+char *_ksr_hname_extra_chars = "";
163
+
159 164
 /**
160 165
  * indexed valid chars in 256-array for 1-byte-index access check
161 166
  */
... ...
@@ -163,7 +168,7 @@ static char _ksr_hname_chars_idx[KSR_HDR_MAP_IDX_SIZE];
163 168
 
164 169
 
165 170
 /**
166
- * init header name parsing structures and indexes
171
+ * init header name parsing structures and indexes at very beginning of start up
167 172
  */
168 173
 int ksr_hname_init_index(void)
169 174
 {
... ...
@@ -195,6 +200,20 @@ int ksr_hname_init_index(void)
195 200
 	return 0;
196 201
 }
197 202
 
203
+/**
204
+ * init header name parsing structures and indexes after config parsing
205
+ */
206
+int ksr_hname_init_config(void)
207
+{
208
+	int i;
209
+
210
+	for(i=0; _ksr_hname_extra_chars[i] != 0; i++) {
211
+		_ksr_hname_chars_idx[_ksr_hname_extra_chars[i]] = 1;
212
+	}
213
+
214
+	return 0;
215
+}
216
+
198 217
 /**
199 218
  * parse the sip header name in the buffer starting at 'begin' till before 'end'
200 219
  * - fills hdr structure (must not be null)
... ...
@@ -39,5 +39,6 @@ char* parse_hname2(char* const begin, const char* const end, struct hdr_field* c
39 39
 char* parse_hname2_short(char* const begin, const char* const end, struct hdr_field* const hdr);
40 40
 
41 41
 int ksr_hname_init_index(void);
42
+int ksr_hname_init_config(void);
42 43
 
43 44
 #endif /* PARSE_HNAME2_H */
... ...
@@ -2545,6 +2545,8 @@ try_again:
2545 2545
 	/* init lookup for core event routes */
2546 2546
 	sr_core_ert_init();
2547 2547
 
2548
+	ksr_hname_init_config();
2549
+
2548 2550
 	if (dont_fork_cnt)
2549 2551
 		dont_fork = dont_fork_cnt;	/* override by command line */
2550 2552