diff options
Diffstat (limited to 'libempathy/empathy-utils.c')
-rw-r--r-- | libempathy/empathy-utils.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index b8f54baa4..0efe3a180 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -27,17 +27,15 @@ */ #include "config.h" +#include "empathy-utils.h" #include <glib/gi18n-lib.h> - -#include <libxml/uri.h> #include <dbus/dbus-protocol.h> +#include <math.h> #include "empathy-client-factory.h" -#include "empathy-utils.h" #include "empathy-presence-manager.h" - -#include <extensions/extensions.h> +#include "extensions.h" #include <math.h> @@ -111,36 +109,36 @@ empathy_init (void) } gboolean -empathy_xml_validate (xmlDoc *doc, - const gchar *dtd_filename) +empathy_xml_validate_from_resource (xmlDoc *doc, + const gchar *dtd_resourcename) { - gchar *path; - xmlChar *escaped; + GBytes *resourcecontents; + gconstpointer resourcedata; + gsize resourcesize; + xmlParserInputBufferPtr buffer; xmlValidCtxt cvp; xmlDtd *dtd; + GError *error = NULL; gboolean ret; - path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "libempathy", - dtd_filename, NULL); - if (!g_file_test (path, G_FILE_TEST_EXISTS)) + DEBUG ("Loading dtd resource %s", dtd_resourcename); + + resourcecontents = g_resources_lookup_data (dtd_resourcename, G_RESOURCE_LOOKUP_FLAGS_NONE, &error); + if (error != NULL) { - g_free (path); - path = g_build_filename (DATADIR, "empathy", dtd_filename, NULL); + g_warning ("Unable to load dtd resource '%s': %s", dtd_resourcename, error->message); + g_error_free (error); + return FALSE; } - - DEBUG ("Loading dtd file %s", path); - - /* The list of valid chars is taken from libxml. */ - escaped = xmlURIEscapeStr ((const xmlChar *) path, - (const xmlChar *)":@&=+$,/?;"); - g_free (path); + resourcedata = g_bytes_get_data (resourcecontents, &resourcesize); + buffer = xmlParserInputBufferCreateStatic (resourcedata, resourcesize, XML_CHAR_ENCODING_UTF8); memset (&cvp, 0, sizeof (cvp)); - dtd = xmlParseDTD (NULL, escaped); + dtd = xmlIOParseDTD (NULL, buffer, XML_CHAR_ENCODING_UTF8); ret = xmlValidateDtd (&cvp, doc, dtd); - xmlFree (escaped); xmlFreeDtd (dtd); + g_bytes_unref (resourcecontents); return ret; } |