[asterisk-dev] [asterisk-commits] murf: trunk r89272 - /trunk/main/pbx.c

Luigi Rizzo rizzo at icir.org
Wed Nov 21 01:55:29 CST 2007


On Tue, Nov 20, 2007 at 07:29:08PM -0700, Steve Murphy wrote:
> On Fri, 2007-11-16 at 09:35 -0800, Luigi Rizzo wrote:
> > On Fri, Nov 16, 2007 at 10:07:54AM -0700, Steve Murphy wrote:
> 
> > > So, my system interprets this by assigning weights to each pattern char,
> > > where, right now, N gets 98, Z gets 99, X gets 100, . and ! get 200 (per
> > > char matched).
> > > A sing char, non pattern, gets '1', and char ranges ( [0123] ), get a
> > > count of the number of chars in the range, where the LOWEST score wins.
> > 
> > I don't understand why N Z X are 98 99 100 instead of 8 9 10 as the
> > equivalent [2-9] [1-9] [0-9] ranges ?
> > 
> 
> This is because, when notation is a mixture of literal chars, and char
> ranges, that the raw totals don't always reflect what you would
> intuitively think. If a pattern with CID match adds up to around 20
> chars, to make the NZX notation stick out, use numbers near 100. That

it's not a matter of intuition or sticking out.

X and [0-9] and [0-345-9] and variants thereof are exactly the same
pattern and must be dealt with in the same way (in fact, when i
cleaned up the matching code some time ago i was very tempted to
rewrite patterns in a canonical form (replacing X's with [0-9], and
possibly replacing ranges with a 256-bit bitmap containing the exact
list, so it could be scanned in constant time).

I am not saying that the rule for precedence of patterns is
unchangable, but once you pick one rule, you must use it consistently
across your code, or you end up opening more bugs than you fix.

Really, this is not an area where you can afford playing and putting in
small patches to see how they fix one or the other problem.
The correctness of extension matching is something that people
really must rely on, because in the end it is directly involved
with security, billing and so on.

I must really re-empasize my request to have the option to use the
old code in trunk. Be it at compile time, 'extension load' time,
or on the fly as it turns out to be more convenient, but this is
really really necessary.

cheers
luigi



More information about the asterisk-dev mailing list