Review Board 1.7.16


Fix handling of backreferences for ENUM lookups

Review Request #187 - Created March 5, 2009 and submitted

David Vossel
Reviewers
asterisk-dev
mmichelson, russell
Asterisk
enum.c did not handle regex backtraces correctly.  

for example:
input: +44800123123
regex: !^\+44800(.*)$!sip:44800\1@selfnet.at!

^\+44800(.*)$ matches to 123123

The '\1' in the regex is a backtrace that requires a pattern match to be inserted.  The way the code used to work is that it would find the backtrace and insert the entire input string minus the '+'.  This is ghetto...  The regexec() function takes in a variable called pmatch which is an array of structs containing the start and end indexes for each backtrace substring.  The original code actually passed the pmatch array pointer into regexec but never did anything with it.  Now when a backtrace is found, the backtrace number is looked up in the pmatch array and the correct substring is inserted.

the result was: sip:44804480123123@selfnet.at because 4480123123 was being inserted into the backtrace instead of the correct match, 123123

the new result is sip:4480123123@selfnet.at

http://tools.ietf.org/html/rfc3403 discusses some of this.

 
Review request changed
Updated (March 5, 2009, 11:09 a.m.)
hopefully this fixes everything.  
Ship it!
Posted (March 5, 2009, 11:12 a.m.)
Other than one last tiny thing, this looks good to me.

Nice work, Batman!
/trunk/main/enum.c (Diff revision 3)
 
 
size_t instead of int

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.