From: Andrea Zagli Date: Wed, 6 Jan 2021 08:30:57 +0000 (+0100) Subject: Wrong xml parsing in FormElementValidatorFile. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=257d724f420cbfd82e3d2612e5cc745ed7f9a94d;p=zakform%2Fcgi Wrong xml parsing in FormElementValidatorFile. --- diff --git a/src/formelementvalidatorfile.c b/src/formelementvalidatorfile.c index ad0093d..8c66322 100644 --- a/src/formelementvalidatorfile.c +++ b/src/formelementvalidatorfile.c @@ -120,18 +120,24 @@ zak_form_cgi_form_element_validator_file_xml_parsing (ZakFormElementValidator *v { ZakFormCgiFormElementValidatorFilePrivate *priv = zak_form_cgi_form_element_validator_file_get_instance_private (ZAK_FORM_CGI_FORM_ELEMENT_VALIDATOR_FILE (validator)); - if (xmlStrcmp (xnode->name, (const xmlChar *)"size-min") == 0) + if (xmlGetProp (xnode, (xmlChar *)"size_min") != NULL) { - zak_form_cgi_form_element_validator_file_set_size_min (validator, strtol ((gchar *)xmlNodeGetContent (xnode), NULL, 10)); + zak_form_cgi_form_element_validator_file_set_size_min (validator, strtol ((gchar *)xmlGetProp (xnode, (xmlChar *)"size_min"), NULL, 10)); } - else if (xmlStrcmp (xnode->name, (const xmlChar *)"size-max") == 0) + + if (xmlGetProp (xnode, (xmlChar *)"size_max") != NULL) { - zak_form_cgi_form_element_validator_file_set_size_max (validator, strtol ((gchar *)xmlNodeGetContent (xnode), NULL, 10)); + zak_form_cgi_form_element_validator_file_set_size_max (validator, strtol ((gchar *)xmlGetProp (xnode, (xmlChar *)"size_max"), NULL, 10)); } - else if (xmlStrcmp (xnode->name, (const xmlChar *)"mime-type") == 0) + + if (xmlGetProp (xnode, (xmlChar *)"mime_type") != NULL) + { + zak_form_cgi_form_element_validator_file_set_mime_type (validator, (gchar *)xmlGetProp (xnode, (xmlChar *)"mime_type")); + } + + if (xmlGetProp (xnode, (xmlChar *)"mime_type_message") != NULL) { - zak_form_cgi_form_element_validator_file_set_mime_type (validator, (gchar *)xmlNodeGetContent (xnode)); - zak_form_cgi_form_element_validator_file_set_mime_type_message (validator, (gchar *)xmlGetProp (xnode, (const xmlChar *)"message")); + zak_form_cgi_form_element_validator_file_set_mime_type_message (validator, (gchar *)xmlGetProp (xnode, (xmlChar *)"mime_type_message")); } return TRUE; @@ -428,7 +434,8 @@ zak_form_cgi_form_element_validator_file_get_xml (ZakFormElementValidator *valid xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_cgi_form_element_validator_file"); - xmlSetProp (xnode, (const xmlChar *)"size-min", (const xmlChar *)g_strdup_printf ("%d", zak_form_cgi_form_element_validator_file_get_size_min (validator))); - xmlSetProp (xnode, (const xmlChar *)"size-max", (const xmlChar *)g_strdup_printf ("%d", zak_form_cgi_form_element_validator_file_get_size_max (validator))); - xmlSetProp (xnode, (const xmlChar *)"mime-type", (const xmlChar *)zak_form_cgi_form_element_validator_file_get_mime_type (validator)); + xmlSetProp (xnode, (const xmlChar *)"size_min", (const xmlChar *)g_strdup_printf ("%d", zak_form_cgi_form_element_validator_file_get_size_min (validator))); + xmlSetProp (xnode, (const xmlChar *)"size_max", (const xmlChar *)g_strdup_printf ("%d", zak_form_cgi_form_element_validator_file_get_size_max (validator))); + xmlSetProp (xnode, (const xmlChar *)"mime_type", (const xmlChar *)zak_form_cgi_form_element_validator_file_get_mime_type (validator)); + xmlSetProp (xnode, (const xmlChar *)"mime_type_message", (const xmlChar *)zak_form_cgi_form_element_validator_file_get_mime_type_message (validator)); }