*/
#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>
}
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;
}