FreeRADIUS/freeradius-server — pull request #348 by arr2036 (2013-07-05 16:03:12+00:00)
Title: Don't generate errors on zero length expansions

Rationale
=======
With this fix comparing a zero length attribute to a zero length expansion works as expected.

Before patch
------------------
```
(0) update request {
(0)	Tmp-String-0 := ""
(0) } # update request = notfound
(0) update request {
(0)	Tmp-String-1 := ""
(0) } # update request = notfound
(0) ? if (Tmp-String-0 == "")
(0) ERROR: Evaluation of condition failed for some reason.
(0) ? if (Tmp-String-1 == '')
(0) ? if (Tmp-String-1 == '') -> TRUE
(0) if (Tmp-String-1 == '') {
(0) - entering if (Tmp-String-1 == '') {...}
(0) [ok] = ok
(0) - if (Tmp-String-1 == '') returns ok
```

Note that the contents of the first ``if {}`` statement are never executed, because at two points in the existing code, it treats zero length expansions as failures. This is wrong, and confusing for users, who will expect comparison of a zero length attribute to "" to evaluate to TRUE.

There are a few ways to fix this. One is to not actually create zero length string attributes ever, then just the presence test is to check for zero length as well. People may want to differentiate between present and zero length however.

After patch
----------------
```
(0) update request {
(0)	Tmp-String-0 := ""
(0) } # update request = notfound
(0) update request {
(0)	Tmp-String-1 := ""
(0) } # update request = notfound
(0) ? if (Tmp-String-0 == "")
(0) ? if (Tmp-String-0 == "") -> TRUE
(0) if (Tmp-String-0 == "") {
(0) - entering if (Tmp-String-0 == "") {...}
(0) [ok] = ok
(0) - if (Tmp-String-0 == "") returns ok
(0) ? if (Tmp-String-1 == '')
(0) ? if (Tmp-String-1 == '') -> TRUE
(0) if (Tmp-String-1 == '') {
(0) - entering if (Tmp-String-1 == '') {...}
(0) [ok] = ok
(0) - if (Tmp-String-1 == '') returns ok
```