Patch: fix bodystructure headers parsing
- From: José Dapena Paz <jdapena igalia com>
- To: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Patch: fix bodystructure headers parsing
- Date: Wed, 13 Jan 2010 15:13:06 +0100
Hi,
This patch replaces the completely broken mime headers parsing in
bodystructure with another one that works.
Changelog entry:
* libtinymail-camel/tny-camel-bs-mime-part.c: fix headers
file parsing, using camel mime parser this time.
--
José Dapena Paz <jdapena igalia com>
Igalia
diff --git a/ChangeLog b/ChangeLog
index db168f5..a2040f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2010-01-13 Jose Dapena Paz <jdapena igalia com>
+ * libtinymail-camel/tny-camel-bs-mime-part.c: fix headers
+ file parsing, using camel mime parser this time.
+
* libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
(retrieve_subparts_headers): workaround for Gmail. If we are
accessing a TnyMsg, and it does not have id.HEADER part, then
diff --git a/libtinymail-camel/tny-camel-bs-mime-part.c b/libtinymail-camel/tny-camel-bs-mime-part.c
index 776b60a..b31b4ed 100644
--- a/libtinymail-camel/tny-camel-bs-mime-part.c
+++ b/libtinymail-camel/tny-camel-bs-mime-part.c
@@ -337,25 +337,38 @@ tny_camel_bs_mime_part_get_header_pairs_default (TnyMimePart *self, TnyList *lis
g_free (part_uid);
if (pos_filename && !priv->parent && TNY_IS_MSG (self)) {
- FILE *f = fopen (pos_filename, "r");
- if (f) {
- while (!feof (f)) {
- gchar buffer[1024];
- gchar *ptr;
- memset (buffer, 0, 1024);
- fgets (buffer, 1024, f);
- ptr = strchr (buffer, ':');
- if (ptr) {
- TnyPair *pair;
- *ptr='\0';
- ptr++;
- pair = tny_pair_new (buffer, ptr);
- tny_list_append (list, (GObject *) pair);
- g_object_unref (pair);
- }
- }
+ int fd = open (pos_filename, O_RDONLY);
+ if (fd != -1) {
+ CamelMimeParser *mp;
+ struct _camel_header_raw *headers;
+ char *buf;
+ size_t len;
+ int err;
+
+ mp = camel_mime_parser_new ();
+ camel_mime_parser_init_with_fd (mp, fd);
+
+ camel_mime_parser_step (mp, &buf, &len);
+ headers = camel_mime_parser_headers_raw (mp);
+
+ while (headers) {
+ TnyPair *pair;
+ pair = tny_pair_new (headers->name, headers->value);
+ tny_list_append (list, (GObject *) pair);
+ g_object_unref (pair);
+ headers = headers->next;
+ }
+
+ err = camel_mime_parser_errno (mp);
+
+ if (err != 0) {
+ camel_object_unref (mp);
+ mp = NULL;
+ }
+
+ camel_mime_parser_drop_step (mp);
- fclose (f);
+ close (fd);
}
g_free (pos_filename);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]