Module: sip-router
Branch: kamailio_3.0
Commit: dc2361c509d71d30d82ce6f268f3fd6b3fa28b44
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dc2361c…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Nov 2 15:35:42 2009 +0100
core: kamailio mode config parser fix
- fixed bug in parsing pvars without (), when in #!KAMAILIO mode
Reported-by: Daniel-Constantin Mierla <miconda(a)gmail.com>
---
cfg.lex | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/cfg.lex b/cfg.lex
index c9f09fc..e63cebf 100644
--- a/cfg.lex
+++ b/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"