Multivalued attributes

Herwin Weststrate herwin at
Wed Jul 30 20:08:06 CEST 2014

On 30-07-14 11:51, Phil Mayers wrote:
> On 30/07/14 09:21, Herwin Weststrate wrote:
>> What would the semantics be if a negative comparison operator would be
>> used, like this?
>>    if (Attr[*] !~ /regex/)
>> My intuition would say this would only be true if none of the attributes
>> matches, instead of if at least one of the attributes matches.
> Assuming I've understood correctly, using the analogy of the postgres
> operator, this is more like:
> if (any Attr !~ /regex/)
> i.e. if any of the attributes *don't* match.

That would make the following two expressions different:

  if (Attr[*] !~ /regex/)
  if (!(Attr[*] =~ /regex/))

First one is true if any of the attributes doesn't match the regex, the
second one if none of the attribute match the regex. I would expect them
to return the same. There might be some rule or lemma in mathematical
set theory here, but I'm not really sure about that (especially since
that would probably require explicit any/all-modifiers).

> The regex operators would presumably have the special behaviour of
> setting capture groups for the first of the attributes. This doesn't
> have much meaning for !~

Using capture groups with !~ would require an else (because if the regex
doesn't match, there are no capture groups). Using code like that would
just be stupid:

  if (Attr !~ /(regex)/) {
  } else {
    # Do someting with %{1}

Just write it a little bit different and use =~. But this discussion is
not really related to multivalued attributes.

>> And I'm not sure what the expected result should be in the following
>> statement:
>>    if (Attr[*] > 10)
> Likewise
> if (any Attr > 10)

This gives the same behaviour as with !~, I would expect these two to be
the same

  if (Attr[*] > 10)
  if (!(Attr[*] <= 9))

About a year ago I was working on a small filtering language for an API
which required multi-valued attributes. We changed the use of >, <, <=
and >= to yield to syntax errors when combined with multi-valued
attributes, because nobody here really knew what they were supposed to
do in this context.

Herwin Weststrate

More information about the Freeradius-Users mailing list