Преглед на файлове

core: kamailio mode config parser fix

- fixed bug in parsing pvars without (), when in #!KAMAILIO mode

Reported-by: Daniel-Constantin Mierla <[email protected]>
Andrei Pelinescu-Onciul преди 16 години
родител
ревизия
dc2361c509
променени са 1 файла, в които са добавени 20 реда и са изтрити 1 реда
  1. 20 1
      cfg.lex

+ 20 - 1
cfg.lex

@@ -104,6 +104,7 @@
 	#define SELECT_S                5
 	#define AVP_PVAR_S              6  /* avp or pvar */
 	#define PVAR_P_S                7  /* pvar: $(...)  or $foo(...)*/
+	#define PVARID_S                8  /* $foo.bar...*/
 	#define STR_BETWEEN_S		9
 	#define LINECOMMENT_S            10
 	#define DEFINE_S                11
@@ -169,7 +170,7 @@
 
 /* start conditions */
 %x STRING1 STRING2 STR_BETWEEN COMMENT COMMENT_LN ATTR SELECT AVP_PVAR PVAR_P 
-%x INCLF
+%x PVARID INCLF
 %x LINECOMMENT DEFINE_ID DEFINE_EOL IFDEF_ID IFDEF_EOL IFDEF_SKIP
 
 /* config script types : #!SER  or #!KAMAILIO or #!MAX_COMPAT */
@@ -982,6 +983,19 @@ EAT_ABLE	[\ \t\b\r]
 <PVAR_P>{LPAREN}			{ p_nest++; yymore(); }
 <PVAR_P>.					{ yymore(); }
 
+<PVARID>{ID}|'\.'			{yymore(); }
+<PVARID>{LPAREN}			{	state = PVAR_P_S; BEGIN(PVAR_P);
+								p_nest=1; yymore(); }
+<PVARID>.					{	yyless(yyleng-1);
+								count();
+								addstr(&s_buf, yytext, yyleng);
+								yylval.strval=s_buf.s;
+								memset(&s_buf, 0, sizeof(s_buf));
+								state=INITIAL_S;
+								BEGIN(INITIAL);
+								return PVAR;
+							}
+
 	/* if found retcode => it's a built-in pvar */
 <INITIAL>{RETCODE}			{ count(); yylval.strval=yytext; return PVAR; }
 
@@ -993,6 +1007,9 @@ EAT_ABLE	[\ \t\b\r]
 										return ATTR_MARK;
 										break;
 									case SR_COMPAT_KAMAILIO:
+										state=PVARID_S; BEGIN(PVARID);
+										yymore();
+										break;
 									case SR_COMPAT_MAX:
 									default: 
 										state=AVP_PVAR_S; BEGIN(AVP_PVAR);
@@ -1215,6 +1232,8 @@ EAT_ABLE	[\ \t\b\r]
 													" while parsing"
 													" avp name\n");
 											break;
+										case PVARID_S:
+											p_nest=0;
 										case PVAR_P_S: 
 											LOG(L_CRIT, "ERROR: unexpected EOF"
 													" while parsing pvar name"