25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Escape 'family' field in SQL requests

This is needed for compatibility with CockroachDB, because
'FAMILY' is a reserved keyword in this database.
This commit is contained in:
Evgeny Khramtsov 2019-10-28 12:19:24 +03:00
parent e2b79ea0b6
commit f51ba687e2

View File

@ -102,7 +102,7 @@ set_vcard(LUser, LServer, VCARD,
"!server_host=%(LServer)s", "!server_host=%(LServer)s",
"fn=%(FN)s", "fn=%(FN)s",
"lfn=%(LFN)s", "lfn=%(LFN)s",
"family=%(Family)s", "\"family\"=%(Family)s",
"lfamily=%(LFamily)s", "lfamily=%(LFamily)s",
"given=%(Given)s", "given=%(Given)s",
"lgiven=%(LGiven)s", "lgiven=%(LGiven)s",
@ -136,7 +136,7 @@ search(LServer, Data, AllowReturnAll, MaxMatch) ->
end, end,
case catch ejabberd_sql:sql_query( case catch ejabberd_sql:sql_query(
LServer, LServer,
[<<"select username, fn, family, given, " [<<"select username, fn, \"family\", given, "
"middle, nickname, bday, ctry, " "middle, nickname, bday, ctry, "
"locality, email, orgname, orgunit " "locality, email, orgname, orgunit "
"from vcard_search ">>, "from vcard_search ">>,
@ -192,7 +192,7 @@ remove_user(LUser, LServer) ->
" where lusername=%(LUser)s and %(LServer)H")) " where lusername=%(LUser)s and %(LServer)H"))
end). end).
export(_Server) -> export(_Server) ->
[{vcard, [{vcard,
fun(Host, #vcard{us = {LUser, LServer}, vcard = VCARD}) fun(Host, #vcard{us = {LUser, LServer}, vcard = VCARD})
when LServer == Host -> when LServer == Host ->
@ -227,7 +227,7 @@ export(_Server) ->
"server_host=%(LServer)s", "server_host=%(LServer)s",
"fn=%(FN)s", "fn=%(FN)s",
"lfn=%(LFN)s", "lfn=%(LFN)s",
"family=%(Family)s", "\"family\"=%(Family)s",
"lfamily=%(LFamily)s", "lfamily=%(LFamily)s",
"given=%(Given)s", "given=%(Given)s",
"lgiven=%(LGiven)s", "lgiven=%(LGiven)s",