Match newline in Cisco-AVPair[*]

Arran Cudbard-Bell a.cudbardb at freeradius.org
Wed Apr 15 18:06:53 CEST 2015


> On 15 Apr 2015, at 16:15, Arran Cudbard-Bell <a.cudbardb at freeradius.org> wrote:
> 
> 
>> On 15 Apr 2015, at 15:08, Alan DeKok <aland at deployingradius.com> wrote:
>> 
>> On Apr 15, 2015, at 9:29 AM, Kostas Zorbadelos <kzorba at otenet.gr> wrote:
>>> I am trying to perform a match against the full Cisco-AVPair string
>>> (Cisco-AVPair[*]) to get a specific part. The exact check I am
>>> performing is
>> 
>> It would be better to loop over the Cisco-AVPairs with a "foreach", and the match the one you want.
> 
> No, the way he's doing it should work.

(0)       update request {
(0)         Cisco-AVPair := 'foo=bar'
(0)         Cisco-AVPair += 'bar=baz'
(0)         Cisco-AVPair += 'baz=foo'
(0)       } # update request = noop
(0)       if (&Cisco-AVPair[*] =~ /bar=(.*)/) {
(0)       if (&Cisco-AVPair[*] =~ /bar=(.*)/)  -> TRUE
(0)       if (&Cisco-AVPair[*] =~ /bar=(.*)/)  {
(0)         if ("%{1}" != 'baz') {
(0)         EXPAND %{1}
(0)            --> baz
(0)         if ("%{1}" != 'baz')  -> FALSE
(0)       } # if (&Cisco-AVPair[*] =~ /bar=(.*)/)  = noop
(0)       ... skipping else for request 0: Preceding "if" was taken

It works because the matching is short circuited when it finds a value that matches the regex.
So the capture groups are from the last value that matched.

Anyway, added a test case to make sure it doesn't break in future.

-Arran

Arran Cudbard-Bell <a.cudbardb at freeradius.org>
FreeRADIUS development team

FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 872 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20150415/20a6a87c/attachment.sig>


More information about the Freeradius-Users mailing list