[asterisk-bugs] [Asterisk 0014076]: Extensions configuration is not being sorted correctly

Asterisk Bug Tracker noreply at bugs.digium.com
Tue Dec 16 08:58:47 CST 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=14076 
====================================================================== 
Reported By:                toc
Assigned To:                blitzrage
====================================================================== 
Project:                    Asterisk
Issue ID:                   14076
Category:                   Core/PBX
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.6.0 
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-12-15 06:53 CST
Last Modified:              2008-12-16 08:58 CST
====================================================================== 
Summary:                    Extensions configuration is not being sorted
correctly
Description: 
The matching performed on extensions.conf is not sorting the items as
expected.

Take this example:

[test-ext]
exten => _.,1,NoOp(Match 1)
exten => s-Nothing,1,NoOp(Match 3)
exten => _s.,1,NoOp(Match 2)
exten => _s-.,1,NoOp(Match 4)

The result of:
[test-ext]
exten => _.,1,NoOp(Match 1)
exten => s-Nothing,1,NoOp(Match 3)
exten => _s.,1,NoOp(Match 2)
exten => _s-.,1,NoOp(Match 4)

Is:
— Executing [s-Test at test-ext:1] NoOp("Local/s-Test at test-ext-0cbc;2",
"Match 2") in new stack

I would expect the match to occur on Match 4, this is the closed match
based on the number of items to match on.

Swap them around:
[test-ext]
exten => _.,1,NoOp(Match 1)
exten => s-Nothing,1,NoOp(Match 3)
exten => _s-.,1,NoOp(Match 4)
exten => _s.,1,NoOp(Match 2)

And this is the output:
— Executing [s-Test at test-ext:1] NoOp("Local/s-Test at test-ext-5f64;2",
"Match 4") in new stack

It appears to be inconsistent in applying the matching as I would expect
regardless of entry position, the same results to occur due to the
matching.
====================================================================== 

---------------------------------------------------------------------- 
 (0096440) blitzrage (administrator) - 2008-12-16 08:58
 http://bugs.digium.com/view.php?id=14076#c96440 
---------------------------------------------------------------------- 
OK, after a discussion on IRC and a code review by murf, it seems this is
actually expected behaviour (however it is not documented). I am going to
create some documentation for it this afternoon and then this issue will be
closed.

Basically the issue is that hyphens (-) are ignored in pattern matches. So
what is happening is that:

_s-.

and 

_s.

Are actually the same pattern because the hyphen is ignored. This is the
same reason why I was only seeing 3 matches load up in my dialplan when I
was trying to duplicate your behaviour, and why I also got the "duplicate"
warning when loading the dialplan.

In this case order DOES matter because the 1st listed pattern is going to
win, and the 2nd one will be thrown away.

Hope that all makes sense, and I will expand upon this in the documention
later this afternoon, and will probably write a blog post as well.

Thanks! 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-12-16 08:58 blitzrage      Note Added: 0096440                          
======================================================================




More information about the asterisk-bugs mailing list