]> source.dussan.org Git - rspamd.git/commitdiff
* Handle lua tag in way that it is not required to write additional text:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 1 Jul 2010 10:35:50 +0000 (14:35 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 1 Jul 2010 10:35:50 +0000 (14:35 +0400)
  - <lua src="/some/path" /> instead of <lua ...>fake</lua>
* Strip all starting whitespace symbols from xml texts

src/cfg_xml.c

index 86ac49d937c1c1ea20f91fe826d4cbabbe4de5ba..030ec9b34d7f3374d886b18046223763a4736c78 100644 (file)
@@ -1241,6 +1241,17 @@ rspamd_xml_start_element (GMarkupParseContext *context, const gchar *element_nam
                                /* Create object */
                                ud->section_pointer = check_worker_conf (ud->cfg, NULL);
                        }
+                       else if (g_ascii_strcasecmp (element_name, "lua") == 0) {
+                               g_strlcpy (ud->section_name, element_name, sizeof (ud->section_name));
+                               ud->cur_attrs = process_attrs (ud->cfg, attribute_names, attribute_values);
+                               if (! handle_lua (ud->cfg, ud, ud->cur_attrs, NULL, NULL, ud->cfg, 0)) {
+                                       *error = g_error_new (xml_error_quark (), XML_EXTRA_ELEMENT, "cannot parse tag '%s'", ud->section_name);
+                                       ud->state = XML_ERROR;
+                               }
+                               else {
+                                       ud->state = XML_READ_VALUE;
+                               }
+                       }
                        else if (g_ascii_strcasecmp (element_name, "view") == 0) {
                                ud->state = XML_READ_VIEW;
                                /* Create object */
@@ -1411,8 +1422,13 @@ rspamd_xml_text (GMarkupParseContext *context, const gchar *text, gsize text_len
        struct rspamd_xml_userdata *ud = user_data;
        char *val;
        struct config_file *cfg = ud->cfg;
-
-       if (*text == '\n') {
+       
+       /* Strip space symbols */
+       while (*text && g_ascii_isspace (*text)) {
+               text ++;
+       }
+       if (*text == '\0') {
+               /* Skip empty text */
                return;
        }