Summary: | ASTERISK-01754: [patch] Problems with string quotes,escaping and regular expression in extensions.conf | ||
Reporter: | constfilin (constfilin) | Labels: | |
Date Opened: | 2004-06-03 16:43:48 | Date Closed: | 2004-09-25 02:42:32 |
Priority: | Trivial | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) asterisk-regexp_and_quotes-1.0.patch | |
Description: | I have the latest development version of asterisk. In extensions.conf, I had to match a line ${CALLERID} against the following regular expression: ".+" +<(.+)> The value of ${CALLERID} was (literally, including the quotes) "Constantine Filin" <qqq1> My first attempt to match it was: $[${CALLERID} : ".+" +<(.+)>] But this did not work because in ast_expr.c, function ast_yylex, Asterisk was tokenizing the above line in tokens like "Constantine Filin",<,qqq1, which is - obviously - not what I need. I re-wrote the line: $["${CALLERID}" : ".+" +<(.+)>] Now ast_yylex gave these tokens: "",Constantine,Filin etc, again not what I need. So I wrote some code in ast_yylex and make_str to recognize escapes in the quoted strings. Next next version of the line was $["${CALLERID}" : "\".+\" +<(.+)>"] Now the trouble was that ${CALLERID} already has quotes and I have no means to escape them and convert to \" sequences. My next step was to change pbx.c, function "pbx_substitute_variables_temp" to introduce new build-in function which I called ESCAPEQUOTES. This function replaced all quotes with \" in its argument. The new version of the colon operator was $["${ESCAPEQUOTES(${CALLERID})}" : "\".+\" +<(.+)>"]) But even this version didn't work. A research showed that in ast_expr.c, function "op_colon" called "regcomp" without flag REG_EXTENDED necessary for regular expresions to understand + as a special character. So I changed the call to regcomp in "op_colon" to use extended regular expressions, and after that change everything worked just fine. ****** ADDITIONAL INFORMATION ****** Questions: 1. Are my changes "friendly" to the overal asterisk architecture? 2. How do I contribute my code changes into asterisk CVS? | ||
Comments: | By: Mark Spencer (markster) 2004-06-03 17:18:37 This is not a block bug. I've marked it as "trivial" please read http://www.digium.com/bugguidelines.html which is also linked (in yellow) from the page where you place a bug report for information about how to contribute your patch -- although it sounds like a patch may not be necessary in this case if it's just changing the one flag. Thanks! By: Mark Spencer (markster) 2004-06-05 18:01:26 Can you confirm that all you want us to do is change that one flag? By: constfilin (constfilin) 2004-06-07 22:31:53 regexp_and_quota patch should be applied to the development CVS version that was available at 7:30pm PST. By: constfilin (constfilin) 2004-06-07 22:33:25 Mark, there were other changes besides the extended regexp flag (e.g. I had to add function ESCAPEQUOTES in pbx.c). Therefore I produced a patch. I hope I did everything right. Please see the previous bugnote. By: Mark Spencer (markster) 2004-06-20 10:23:43 We built some special quote handling already now. Can you see if that quote handling helps? By: Mark Spencer (markster) 2004-06-21 14:34:49 I've updated CVS to support the regular extended expressions. The quoting stuff should no longer be necessary. Reopen if this doesn't solve your issue. |