Mercurial > prosody-modules
comparison mod_vjud/mod_vjud.lua @ 879:3a17fc0127b1
mod_vjud: Enforce minimal length of search parameters
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 16 Dec 2012 12:35:43 +0100 |
| parents | 7e40d6680093 |
| children | 312602605269 |
comparison
equal
deleted
inserted
replaced
| 878:6b7a2d1a1879 | 879:3a17fc0127b1 |
|---|---|
| 83 if stanza.attr.type == "get" then | 83 if stanza.attr.type == "get" then |
| 84 origin.send(st.reply(stanza):add_child(get_reply)); | 84 origin.send(st.reply(stanza):add_child(get_reply)); |
| 85 else -- type == "set" | 85 else -- type == "set" |
| 86 local query = stanza.tags[1]; | 86 local query = stanza.tags[1]; |
| 87 local first, last, nick, email = | 87 local first, last, nick, email = |
| 88 (query:get_child_text"first" or false), | 88 s_lower(query:get_child_text"first" or ""), |
| 89 (query:get_child_text"last" or false), | 89 s_lower(query:get_child_text"last" or ""), |
| 90 (query:get_child_text"nick" or false), | 90 s_lower(query:get_child_text"nick" or ""), |
| 91 (query:get_child_text"email" or false); | 91 s_lower(query:get_child_text"email" or ""); |
| 92 | 92 |
| 93 first = #first >= 2 and first; | |
| 94 last = #last >= 2 and last; | |
| 95 nick = #nick >= 2 and nick; | |
| 96 email = #email >= 2 and email; | |
| 93 if not ( first or last or nick or email ) then | 97 if not ( first or last or nick or email ) then |
| 94 origin.send(st.error_reply(stanza, "modify", "not-acceptable", "All fields were empty")); | 98 origin.send(st.error_reply(stanza, "modify", "not-acceptable", "All fields were empty or too short")); |
| 95 return true; | 99 return true; |
| 96 end | 100 end |
| 97 | 101 |
| 98 local reply = st.reply(stanza):query("jabber:iq:search"); | 102 local reply = st.reply(stanza):query("jabber:iq:search"); |
| 99 | 103 |
