[asterisk-bugs] [Asterisk 0013236]: doesn't set ~~EXTEN~~ on the rigth place when a switch statement has been found

Asterisk Bug Tracker noreply at bugs.digium.com
Mon Aug 4 18:46:04 CDT 2008


The following issue has been ASSIGNED. 
====================================================================== 
http://bugs.digium.com/view.php?id=13236 
====================================================================== 
Reported By:                korihor
Assigned To:                murf
====================================================================== 
Project:                    Asterisk
Issue ID:                   13236
Category:                   PBX/pbx_ael
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.4.21.2 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             2008-08-04 18:33 CDT
Last Modified:              2008-08-04 18:46 CDT
====================================================================== 
Summary:                    doesn't set ~~EXTEN~~ on the rigth place when a
switch statement has been found
Description: 
The instruction 'Set(~~EXTEN~~=${EXTEN})' created by pbx_ael is placed on a
wrong location. I understand that the idea is to place it before the first
'switch', but if the first switch is found inside a conditional 'if' there
is a problem, because ~~EXTEN~~ would only be set if this condition is
'true', otherwise 'Set(~~EXTEN~~=${EXTEN})' is never executed and ${EXTEN}
is replaced in the rest of extension with ${~~EXTEN~~} which doesn't
exists. Here is an example:

Dialplan test:

context test {
        0123 => {
                        NoOp("Here EXTEN = ${EXTEN} - good");
                        
                        if ("${CALLERID(num):0:1}" = "2") {

                                switch (${CALLERID(num):1:1}) {
                                        pattern [02]:
                                                goto blacklist;
                                                break;
                                        default:
                                                break;
                                };

                                NoOp("Here EXTEN = ${EXTEN} - fortunately
because first 'switch'");

                        } else if ("${CALLERID(num):0:1}" = "4") {
                                
                                switch (${CALLERID(num):1:1}) {
                                        pattern [03-9]:
                                                goto blacklist;
                                                break;
                                        default:
                                                break;
                                };

                                NoOp("Here EXTEN = ${EXTEN} -
unfortunately because not is first 'switch' - bad ");

                        } else {
                                goto blacklist;
                        }

                        Answer();
                        NoOp("Here EXTEN = ${EXTEN} - good if
CALLERID(num):0:1 = 2\, bad otherwise");
                        Playback(test/${EXTEN}/welcome);
                        Hangup();

blacklist:
                        NoOp("Here EXTEN = ${EXTEN} - good if
CALLERID(num):0:1 = 2\, bad otherwise");
                       
Playback(test/${EXTEN}/you-are-on-blacklist|noanswer);
                        Hangup();
        };

};

[ Context 'test' created by 'pbx_ael' ]
  '0123' =>         1. NoOp("Here EXTEN = ${EXTEN} - good")      
[pbx_ael]
                    2. GotoIf($["${CALLERID(num):0:1}" = "2"]?3:8)
[pbx_ael]
                    3. Set(~~EXTEN~~=${EXTEN})                   
[pbx_ael]
                    4. Goto(sw-2-${CALLERID(num):1:1}|10)        
[pbx_ael]
                    5. NoOp(Finish switch-if-test-1-2)           
[pbx_ael]
                    6. NoOp("Here EXTEN = ${~~EXTEN~~} - fortunately
because first 'switch'") [pbx_ael]
                    7. Goto(15)                                  
[pbx_ael]
                    8. GotoIf($["${CALLERID(num):0:1}" = "4"]?9:13)
[pbx_ael]
                    9. Goto(sw-4-${CALLERID(num):1:1}|10)        
[pbx_ael]
                    10. NoOp(Finish switch-if-if-test-1-3-4)     
[pbx_ael]
                    11. NoOp("Here EXTEN = ${~~EXTEN~~} - unfortunately
because not is first 'switch' - bad ") [pbx_ael]
                    12. Goto(14)                                 
[pbx_ael]
                    13. Goto(blacklist)                          
[pbx_ael]
                    14. NoOp(Finish if-if-test-1-3)              
[pbx_ael]
                    15. NoOp(Finish if-test-1)                   
[pbx_ael]
                    16. Answer()                                 
[pbx_ael]
                    17. NoOp("Here EXTEN = ${~~EXTEN~~} - good if
CALLERID(num):0:1 = 2, bad otherwise") [pbx_ael]
                    18. Playback(test/${~~EXTEN~~}/welcome)      
[pbx_ael]
                    19. Hangup()                                 
[pbx_ael]
     [blacklist]    20. NoOp("Here EXTEN = ${~~EXTEN~~} - good if
CALLERID(num):0:1 = 2, bad otherwise") [pbx_ael]
                    21.
Playback(test/${~~EXTEN~~}/you-are-on-blacklist|noanswer) [pbx_ael]
                    22. Hangup()                                 
[pbx_ael]
  'sw-2-' =>        10. Goto(sw-2-.|10)                          
[pbx_ael]
  'sw-4-' =>        10. Goto(sw-4-.|10)                          
[pbx_ael]
  '_sw-2-[02]' =>   10. Goto(0123|blacklist)                     
[pbx_ael]
                    11. Goto(0123|5)                             
[pbx_ael]
  '_sw-2-.' =>      10. Goto(0123|5)                             
[pbx_ael]
  '_sw-4-[03-9]' => 10. Goto(0123|blacklist)                     
[pbx_ael]
                    11. Goto(0123|10)                            
[pbx_ael]
  '_sw-4-.' =>      10. Goto(0123|10)                            
[pbx_ael]

-= 7 extensions (30 priorities) in 1 context. =-

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-08-04 18:46 snuffy         Status                   new => assigned     
2008-08-04 18:46 snuffy         Assigned To               => murf            
======================================================================




More information about the asterisk-bugs mailing list