Unlang regular expression string expansion.
Hi, HP access point with mac authentication. Sends mac as User-Name in lower case, Sends mac as Calling-Station-ID in upper case. Check to see if mac based authentication is being attempted is if User-Name == Calling-Station-ID. As the case differs the two don't match. if(%{User-Name} =~ /%{Calling-Station-ID}/i){ Doesn't expand %{Calling-Station-ID} , but thats expected. if(%{User-Name} =~ "/%{Calling-Station-ID}/i"){ Gives error. Leaves no way to do case insensitive equality checks between strings with unlang... Any chance of expanding regex strings before passing them to the regex parser ? Or == becomes non-strict equality and === becomes strict equality. Thanks, Arran
On Wed, 2007-08-22 at 16:49 +0100, Arran Cudbard-Bell wrote:
Hi,
HP access point with mac authentication.
Sends mac as User-Name in lower case, Sends mac as Calling-Station-ID in upper case.
Yeah, this is tedious; a general-purpose text transformation mechanisms would be useful - something like the cli "tr" program but in-server. Maybe an expansion: update request { Calling-Station-Id = `%{tr:[:lower:] [:upper:] %{Calling-Station-Id}}` }
Arran Cudbard-Bell wrote:
if(%{User-Name} =~ /%{Calling-Station-ID}/i){
Doesn't expand %{Calling-Station-ID} , but thats expected.
It could... edit src/main/evaluate.c, look in function getregex(), and change the final "return T_BARE_WORD" to "return T_DOUBLE_QUOTED_STRING" After all, if you can use variables in Perl's regular expressions, why not here?
Any chance of expanding regex strings before passing them to the regex parser ?
A one-line patch. It should probably go in, because it's just too useful to leave out. Alan DeKok.
participants (3)
-
Alan DeKok -
Arran Cudbard-Bell -
Phil Mayers