rlm_sql and UTF8 encoded strings
Hello, I have a problem with german umlauts in Acct-(Multi-)Session-Id. RFC2866 states that the string should be UTF8 encoded which it is. But the sql_escape_func of rlm_sql does not account for utf characters and iterates the string byte by byte. What approach would be best here? Regards Stephan -- i. A. Stephan Jäger Abteilung Dienste Telefon: (0441)8000-2873 Telefax: (0441)8000-2599 mailto:stephan.jaeger@ewetel.de ___________________________________ EWE TEL GmbH Cloppenburger Straße 310 26133 Oldenburg Handelsregister Amtsgericht Oldenburg HRB 3723 Vorsitzender des Aufsichtsrates: Heiko Harms Geschäftsführung: Hans-Joachim Iken (Vorsitzender), Dr. Norbert Schulz, Dirk Thole Homepage: http://www.ewetel.de/
Stephan Jaeger wrote:
I have a problem with german umlauts in Acct-(Multi-)Session-Id. RFC2866 states that the string should be UTF8 encoded which it is. But the sql_escape_func of rlm_sql does not account for utf characters and iterates the string byte by byte. What approach would be best here?
src/lib/print.c contains a function utf8_char. It could be made public, and used to do proper character checks on UTF-8 strings. However, we can't make this functionality the default in the SQL module. I would suggest making it optional in the SQL module: sql { utf8 = yes # ALL characters in ALL tables are utf-8 ... } Then in sql_escape_func(), check for utf8, and use the utf8_char function to skip ahead, instead of doing "str++" Alan DeKok.
Alan DeKok wrote:
Stephan Jaeger wrote:
Then in sql_escape_func(), check for utf8, and use the utf8_char function to skip ahead, instead of doing "str++"
Here's my solution, maybe there's a smarter one which does not require cloning sql_escape_func. I splitted this in several patches for clarity. Regards Stephan
Stephan Jaeger wrote:
Here's my solution, maybe there's a smarter one which does not require cloning sql_escape_func.
Not really... until the escape functions support being passed module instances, this is the simplest approach.
I splitted this in several patches for clarity.
Please try using "git". github make it trivial to fork the server, apply your own patches, and then tell me about the changes. That way, your name also goes into the commit, too. :) Alan DeKok.
participants (2)
-
Alan DeKok -
Stephan Jaeger