aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/camel-mime-part.c22
-rw-r--r--camel/camel-mime-part.h4
-rw-r--r--camel/camel-mime-utils.c26
-rw-r--r--camel/camel-mime-utils.h3
5 files changed, 64 insertions, 0 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index e79d88f11a..62674276b9 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,12 @@
+2001-05-11 Dan Winship <danw@ximian.com>
+
+ * camel-mime-utils.c (header_location_decode): Decode
+ Content-Location, either correctly or Netscape-generated-brokenly.
+
+ * camel-mime-part.c (camel_mime_part_set_content_location,
+ camel_mime_part_get_content_location, etc): Deal with
+ Content-Location header.
+
2001-05-11 Jeffrey Stedfast <fejj@ximian.com>
* providers/smtp/camel-smtp-transport.c (smtp_auth): Don't check
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index e62f7cce27..956e0c1554 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -51,6 +51,7 @@ typedef enum {
HEADER_CONTENT_ID,
HEADER_ENCODING,
HEADER_CONTENT_MD5,
+ HEADER_CONTENT_LOCATION,
HEADER_CONTENT_LANGUAGES,
HEADER_CONTENT_TYPE
} CamelHeaderType;
@@ -97,6 +98,7 @@ init_header_name_table()
g_hash_table_insert (header_name_table, "Content-id", (gpointer)HEADER_CONTENT_ID);
g_hash_table_insert (header_name_table, "Content-Transfer-Encoding", (gpointer)HEADER_ENCODING);
g_hash_table_insert (header_name_table, "Content-MD5", (gpointer)HEADER_CONTENT_MD5);
+ g_hash_table_insert (header_name_table, "Content-Location", (gpointer)HEADER_CONTENT_LOCATION);
g_hash_table_insert (header_name_table, "Content-Type", (gpointer)HEADER_CONTENT_TYPE);
header_formatted_table = g_hash_table_new(g_strcase_hash, g_strcase_equal);
@@ -141,6 +143,7 @@ camel_mime_part_init (gpointer object, gpointer klass)
camel_mime_part->disposition = NULL;
camel_mime_part->content_id = NULL;
camel_mime_part->content_MD5 = NULL;
+ camel_mime_part->content_location = NULL;
camel_mime_part->content_languages = NULL;
camel_mime_part->encoding = CAMEL_MIME_PART_ENCODING_DEFAULT;
}
@@ -154,6 +157,7 @@ camel_mime_part_finalize (CamelObject *object)
g_free (mime_part->description);
g_free (mime_part->content_id);
g_free (mime_part->content_MD5);
+ g_free (mime_part->content_location);
string_list_free (mime_part->content_languages);
header_disposition_unref(mime_part->disposition);
@@ -221,6 +225,10 @@ process_header(CamelMedium *medium, const char *header_name, const char *header_
g_free(mime_part->content_MD5);
mime_part->content_MD5 = g_strdup(header_value);
break;
+ case HEADER_CONTENT_LOCATION:
+ g_free(mime_part->content_location);
+ mime_part->content_location = header_location_decode(header_value);
+ break;
case HEADER_CONTENT_TYPE:
if (mime_part->content_type)
header_content_type_unref (mime_part->content_type);
@@ -404,6 +412,20 @@ camel_mime_part_get_content_MD5 (CamelMimePart *mime_part)
return mime_part->content_MD5;
}
+/* **** Content-MD5: */
+
+void
+camel_mime_part_set_content_location (CamelMimePart *mime_part, const char *location)
+{
+ camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Location", location);
+}
+
+const gchar *
+camel_mime_part_get_content_location (CamelMimePart *mime_part)
+{
+ return mime_part->content_location;
+}
+
/* **** Content-Transfer-Encoding: */
void
diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h
index 75f7bff6db..4d844af3fd 100644
--- a/camel/camel-mime-part.h
+++ b/camel/camel-mime-part.h
@@ -66,6 +66,7 @@ struct _CamelMimePart
CamelMimeDisposition *disposition;
gchar *content_id;
gchar *content_MD5;
+ gchar *content_location;
GList *content_languages;
CamelMimePartEncodingType encoding;
@@ -102,6 +103,9 @@ const gchar *camel_mime_part_get_content_id (CamelMimePart *mime_part);
void camel_mime_part_set_content_MD5 (CamelMimePart *mime_part, const char *);
const gchar *camel_mime_part_get_content_MD5 (CamelMimePart *mime_part);
+void camel_mime_part_set_content_location (CamelMimePart *mime_part, const char *);
+const gchar *camel_mime_part_get_content_location (CamelMimePart *mime_part);
+
void camel_mime_part_set_encoding (CamelMimePart *mime_part, CamelMimePartEncodingType type);
CamelMimePartEncodingType camel_mime_part_get_encoding (CamelMimePart *mime_part);
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 7e486689ef..fbfbb3e5be 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -2842,6 +2842,32 @@ header_decode_date(const char *in, int *saveoffset)
return t;
}
+char *
+header_location_decode(const char *in)
+{
+ const char *p;
+
+ /* Sigh. RFC2557 says:
+ * content-location = "Content-Location:" [CFWS] URI [CFWS]
+ * where URI is restricted to the syntax for URLs as
+ * defined in Uniform Resource Locators [URL] until
+ * IETF specifies other kinds of URIs.
+ *
+ * But Netscape puts quotes around the URI when sending web
+ * pages.
+ */
+
+ header_decode_lwsp(&in);
+ if (*in == '"')
+ return header_decode_quoted_string(&in);
+ else {
+ for (p = in; *p && !is_lwsp(*p); p++)
+ ;
+ return g_strndup(in, p - in);
+ }
+}
+
+
/* extra rfc checks */
#define CHECKS
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index 7805c27456..2739e5e0f9 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -175,6 +175,9 @@ void header_references_list_append_asis(struct _header_references **list, char *
int header_references_list_size(struct _header_references **list);
struct _header_references *header_references_dup(const struct _header_references *list);
+/* decode content-location */
+char *header_location_decode(const char *in);
+
/* decode the mime-type header */
void header_mime_decode(const char *in, int *maj, int *min);