From: Vsevolod Stakhov Date: Fri, 12 Jan 2018 21:27:30 +0000 (+0000) Subject: [Minor] Start arrays support in xmlrpc output X-Git-Tag: 1.7.0~290 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=07bb08245320b20c81df9c50cfeabb3baffbd935;p=rspamd.git [Minor] Start arrays support in xmlrpc output --- diff --git a/src/lua/lua_xmlrpc.c b/src/lua/lua_xmlrpc.c index 27d944712..01850af70 100644 --- a/src/lua/lua_xmlrpc.c +++ b/src/lua/lua_xmlrpc.c @@ -132,6 +132,12 @@ xmlrpc_start_element (GMarkupParseContext *context, lua_newtable (ud->L); ud->depth++; } + else if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 14; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } else if (g_ascii_strcasecmp (name, "string") == 0) { ud->parser_state = 11; ud->got_text = FALSE; @@ -202,6 +208,66 @@ xmlrpc_start_element (GMarkupParseContext *context, lua_newtable (ud->L); ud->depth++; } + else if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 14; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 14: + /* Parse array */ + /* Expect data */ + if (g_ascii_strcasecmp (name, "data") == 0) { + ud->parser_state = 15; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 15: + /* Accept array value */ + if (g_ascii_strcasecmp (name, "value") == 0) { + ud->parser_state = 16; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 16: + /* Parse any values */ + /* Primitives */ + if (g_ascii_strcasecmp (name, "string") == 0) { + ud->parser_state = 11; + ud->got_text = FALSE; + } + else if (g_ascii_strcasecmp (name, "int") == 0) { + ud->parser_state = 12; + ud->got_text = FALSE; + } + else if (g_ascii_strcasecmp (name, "double") == 0) { + ud->parser_state = 13; + ud->got_text = FALSE; + } + /* Structure */ + else if (g_ascii_strcasecmp (name, "struct") == 0) { + ud->parser_state = 5; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } + else if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 14; + /* Create new param of table type */ + lua_newtable (ud->L); + ud->depth++; + } else { /* Error state */ ud->parser_state = 99; @@ -348,6 +414,39 @@ xmlrpc_end_element (GMarkupParseContext *context, ud->parser_state = 99; } break; + case 14: + /* Got tag array */ + if (g_ascii_strcasecmp (name, "array") == 0) { + ud->parser_state = 4; + ud->depth--; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 15: + /* Got tag data */ + if (g_ascii_strcasecmp (name, "data") == 0) { + ud->parser_state = 14; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; + case 17: + /* Got tag value */ + if (g_ascii_strcasecmp (name, "value") == 0) { + guint tbl_len = rspamd_lua_table_size (ud->L, -2); + lua_rawseti (ud->L, -2, tbl_len + 1); + ud->parser_state = 15; + } + else { + /* Error state */ + ud->parser_state = 99; + } + break; } if (ud->parser_state == 99) {