On Tue, 2013-06-11 at 11:50 -0400, Alan DeKok wrote:
Stelian Ionescu wrote:
No, it's a regression. On 2.* commas and apostrophes part of the literal query as embedded in dialup.conf didn't get escaped, only the various expansions; but now the whole query gets escaped .
It's a bug fix.
In 2.x, the '?' character wasn't listed in "safe-characters". Yet it wasn't escaped. That's wrong.
The expansion functionality was re-written for v3. It's now less code, with better error messages, and fewer weird corner cases. As a side effect, the "safe-characters" is now processed correctly. Previously, it wasn't.
The "safe-characters" list is editable for a reason. If '.' and '?' should be listed by default, we can go fix that. But the functionality WILL NOT be reverted. The old code was wrong.
And here's part of a debugging session of xlat_process on that query: (gdb) print *node $13 = {fmt = 0xb84e90 "SELECT id, inner_id, attribute, val, op FROM radcheck(COALESCE(NULLIF('", len = 71, da = 0x0, num = 0, tag = 0, list = PAIR_LIST_UNKNOWN, ref = REQUEST_UNKNOWN, type = XLAT_LITERAL, next = 0xb850d0, child = 0x0, alternate = 0x0, xlat = 0x0} (gdb) n (gdb) n (gdb) print *node $14 = {fmt = 0xb84ed9 "Event-Timestamp", len = 0, da = 0x65c290, num = 0, tag = -128, list = PAIR_LIST_REQUEST, ref = REQUEST_CURRENT, type = XLAT_ATTRIBUTE, next = 0xb85180, child = 0x0, alternate = 0x0, xlat = 0x0} (gdb) print array[0] $15 = 0xb85b40 "SELECT id, inner_id, attribute, val, op FROM radcheck(COALESCE(NULLIF('" (gdb) n (gdb) print array[1] $16 = 0xb85c80 "Jun 11 2013 17:25:54 CEST" (gdb) n (gdb) print *node $17 = {fmt = 0xb84ee9 "', ''), '%S')::timestamptz,'", len = 28, da = 0x0, num = 0, tag = 0, list = PAIR_LIST_UNKNOWN, ref = REQUEST_UNKNOWN, type = XLAT_PERCENT, next = 0xb85230, child = 0x0, alternate = 0x0, xlat = 0x0} (gdb) n (gdb) print array[2] $18 = 0xb860e0 "=27=2C =27=27=29=2C =271970-01-01 01:00:00=27=29::timestamptz=2C=27" (gdb) n (gdb) print *node $19 = {fmt = 0xb84f07 "SQL-User-Name", len = 0, da = 0x79bf38, num = 0, tag = -128, list = PAIR_LIST_REQUEST, ref = REQUEST_CURRENT, type = XLAT_ATTRIBUTE, next = 0xb852e0, child = 0x0, alternate = 0x0, xlat = 0x0} (gdb) n (gdb) print array[3] $20 = 0xb86540 "test" The third node as returned by the tokenizer is incorrect: «', ''), '%S')::timestamptz,'» should be three nodes not one, first «', ''), '» as XLAT_LITERAL, then «S» as XLAT_PERCENT then «')::timestamptz,'» as XLAT_LITERAL. -- Stelian Ionescu a.k.a. fe[nl]ix Quidquid latine dictum sit, altum videtur. http://common-lisp.net/project/iolib