[asterisk-dev] [Code Review] Fix handling of backreferences for ENUM lookups
David Vossel
dvossel at digium.com
Thu Mar 5 17:09:29 CST 2009
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.digium.com/r/187/
-----------------------------------------------------------
(Updated 2009-03-05 17:09:29.517352)
Review request for Asterisk Developers, Russell Bryant and Mark Michelson.
Changes
-------
hopefully this fixes everything.
Summary
-------
enum.c did not handle regex backtraces correctly.
for example:
input: +44800123123
regex: !^\+44800(.*)$!sip:44800\1 at 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 at selfnet.at because 4480123123 was being inserted into the backtrace instead of the correct match, 123123
the new result is sip:4480123123 at selfnet.at
http://tools.ietf.org/html/rfc3403 discusses some of this.
Diffs (updated)
-----
/trunk/main/enum.c 180005
Diff: http://reviewboard.digium.com/r/187/diff
Testing
-------
Thanks,
David
More information about the asterisk-dev
mailing list