[evolution-kolab] libekolabconv: decode and validate XFB data before passing on to EClient



commit 423fdc27f335a0381e6adebe33576622f806fc23
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Sat Nov 24 19:47:06 2012 +0100

    libekolabconv: decode and validate XFB data before passing on to EClient
    
    * after retrieving the free/busy icalendar from the
      kolab server, make sure it is base64-decoded and
      valid UTF-8 before passing it on to the EClient

 src/libekolabconv/main/src/kolab-conv.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/libekolabconv/main/src/kolab-conv.c b/src/libekolabconv/main/src/kolab-conv.c
index fe56ee6..fa42714 100644
--- a/src/libekolabconv/main/src/kolab-conv.c
+++ b/src/libekolabconv/main/src/kolab-conv.c
@@ -32,6 +32,7 @@
 #include "evolution/evolution.h"
 #include "kolab/kolab.h"
 #include "logging.h"
+#include "util.h"
 #include "kolab/kolab-util.h"
 
 /**
@@ -169,13 +170,12 @@ kolabconv_cal_util_freebusy_ecalcomp_new_from_ics (const gchar *ics_string,
 	ECalComponent *ecalcomp_tmp = NULL;
 	icalcomponent *icalcomp_ics = NULL;
 	icalcomponent *icalcomp_vfb = NULL;
+	icalcomponent_kind kind = ICAL_NO_COMPONENT;
 	GError *tmp_err = NULL;
-	gboolean set_ical_ok = FALSE;
+	gboolean ok = FALSE;
 
 	g_return_val_if_fail (err == NULL || *err == NULL, NULL);
 
-	/* TODO: sanity-check incoming data */
-
 	if (nbytes <= 0) {
 		g_debug ("kolabconv_cal_util_fb_new_ecalcomp_from_request: empty server response");
 		g_set_error (&tmp_err,
@@ -185,7 +185,7 @@ kolabconv_cal_util_freebusy_ecalcomp_new_from_ics (const gchar *ics_string,
 		goto cleanup;
 	}
 
-	icalcomp_ics = (icalcomponent *) e_cal_util_parse_ics_string (ics_string);
+	icalcomp_ics = (icalcomponent *) icalparser_parse_string (ics_string);
 
 	if (icalcomp_ics == NULL) {
 		g_debug ("kolabconv_cal_util_fb_new_ecalcomp_from_request: cannot parse server response");
@@ -196,6 +196,10 @@ kolabconv_cal_util_freebusy_ecalcomp_new_from_ics (const gchar *ics_string,
 		goto cleanup;
 	}
 
+	kind = icalcomponent_isa (icalcomp_ics);
+	if (kind != ICAL_VCALENDAR_COMPONENT)
+		goto cleanup;
+
 	icalcomp_vfb = icalcomponent_get_first_component (icalcomp_ics, ICAL_VFREEBUSY_COMPONENT);
 
 	if (icalcomp_vfb == NULL) {
@@ -207,10 +211,12 @@ kolabconv_cal_util_freebusy_ecalcomp_new_from_ics (const gchar *ics_string,
 		goto cleanup;
 	}
 
+	klb_conv_xfb_base64_make_utf8_valid (icalcomp_vfb);
+
 	ecalcomp_tmp = e_cal_component_new ();
-	set_ical_ok = e_cal_component_set_icalcomponent (ecalcomp_tmp, icalcomp_vfb);
+	ok = e_cal_component_set_icalcomponent (ecalcomp_tmp, icalcomp_vfb);
 
-	if (! set_ical_ok) {
+	if (! ok) {
 		g_debug ("kolabconv_cal_util_fb_new_ecalcomp_from_request: unsupported component type");
 		g_set_error (&tmp_err,
 		             KOLABCONV_ERROR_READ_KOLAB,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]