Properly shortcircuit regex
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14417 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
dfc05435c5
commit
1b13f8894e
|
@ -7,7 +7,7 @@
|
||||||
<!-- query can be changed, but fields must be in the same order, and the number parameter must be ? -->
|
<!-- query can be changed, but fields must be in the same order, and the number parameter must be ? -->
|
||||||
<add key="query" value="SELECT gateways.gateway_ip, gateways.group, gateways.limit, gateways.techprofile, numbers.acctcode, numbers.translated from gateways, numbers where numbers.number = ? and numbers.gateway_id = gateways.gateway_id;" />
|
<add key="query" value="SELECT gateways.gateway_ip, gateways.group, gateways.limit, gateways.techprofile, numbers.acctcode, numbers.translated from gateways, numbers where numbers.number = ? and numbers.gateway_id = gateways.gateway_id;" />
|
||||||
|
|
||||||
<!-- To avoid other injections, the incoming number will remove characters matching this regex. Default [^0-9#\*] allows only digits, # and *.-->
|
<!-- To avoid other injections, the incoming number will remove characters matching this regex. Default [^0-9#\*] allows only digits, # and *. Use (?!.) to disable. -->
|
||||||
<add key="numberRegexFilter" value="[^0-9#\*]" />
|
<add key="numberRegexFilter" value="[^0-9#\*]" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
|
@ -48,7 +48,7 @@ module easyroute =
|
||||||
let regexOpts = Text.RegularExpressions.RegexOptions.Compiled ||| Text.RegularExpressions.RegexOptions.CultureInvariant
|
let regexOpts = Text.RegularExpressions.RegexOptions.Compiled ||| Text.RegularExpressions.RegexOptions.CultureInvariant
|
||||||
let lookup (number: string) sep =
|
let lookup (number: string) sep =
|
||||||
try
|
try
|
||||||
let number = if numberRegexFilter = "" then number else Text.RegularExpressions.Regex.Replace(number, numberRegexFilter, "", regexOpts)
|
let number = if numberRegexFilter = "(?!.)" then number else Text.RegularExpressions.Regex.Replace(number, numberRegexFilter, "", regexOpts)
|
||||||
use conn = new Odbc.OdbcConnection(connString)
|
use conn = new Odbc.OdbcConnection(connString)
|
||||||
use comm = new Odbc.OdbcCommand(query, conn)
|
use comm = new Odbc.OdbcCommand(query, conn)
|
||||||
comm.Parameters.AddWithValue("@number", number) |> ignore
|
comm.Parameters.AddWithValue("@number", number) |> ignore
|
||||||
|
|
Loading…
Reference in New Issue