[evolution-patches] mail, fix for 67496.
- From: Not Zed <notzed ximian com>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] mail, fix for 67496.
- Date: Mon, 01 Nov 2004 13:02:08 +0800
plays with the content-base stuff some more. should be more like rfc2110, with some workability fallbacks too.
passes test mails and other test cases anyway
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3444.2.24
diff -u -p -r1.3444.2.24 ChangeLog
--- mail/ChangeLog 19 Oct 2004 03:31:08 -0000 1.3444.2.24
+++ mail/ChangeLog 1 Nov 2004 05:10:22 -0000
@@ -1,3 +1,16 @@
+2004-11-01 Not Zed <NotZed Ximian com>
+
+ ** See bug #67496.
+
+ * em-format-html.c (efh_text_html): use the base on the emformat
+ to calculate our absolute iframe uri.
+ (efh_multipart_related): same as emf_multipart_related.
+
+ * em-format.c (emf_multipart_related): remove content-location
+ handling, now done in format_part_as.
+ (em_format_part_as): track content-base (& absolute
+ content-location) of all parts here.
+
2004-10-11 Not Zed <NotZed Ximian com>
** See bug #67014.
Index: mail/em-format-html.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format-html.c,v
retrieving revision 1.63.4.2
diff -u -p -r1.63.4.2 em-format-html.c
--- mail/em-format-html.c 24 Sep 2004 04:05:37 -0000 1.63.4.2
+++ mail/em-format-html.c 1 Nov 2004 05:10:23 -0000
@@ -797,7 +797,7 @@ efh_write_text_html(EMFormat *emf, Camel
static void
efh_text_html(EMFormatHTML *efh, CamelStream *stream, CamelMimePart *part, EMFormatHandler *info)
{
- const char *location, *base, *tmp;
+ const char *location;
EMFormatPURI *puri;
char *cid = NULL;
@@ -806,43 +806,27 @@ efh_text_html(EMFormatHTML *efh, CamelSt
"<table bgcolor=\"#%06x\" cellspacing=0 cellpadding=0 width=100%%><tr><td>\n"
"<!-- text/html -->\n",
efh->frame_colour & 0xffffff, efh->content_colour & 0xffffff);
-
- if ((base = camel_medium_get_header((CamelMedium *)part, "Content-Base"))) {
- char *base_url;
- size_t len;
-
- len = strlen(base);
- if (*base == '"' && *(base + len - 1) == '"') {
- len -= 2;
- base_url = alloca(len + 1);
- memcpy(base_url, base + 1, len);
- base_url[len] = '\0';
- base = base_url;
- }
-
- /* FIXME: set base needs to go on the gtkhtml stream? */
- gtk_html_set_base(efh->html, base);
- }
+ /* TODO: perhaps we don't need to calculate this anymore now base is handled better */
/* calculate our own location string so add_puri doesn't do it
for us. our iframes are special cases, we need to use the
proper base url to access them, but other children parts
shouldn't blindly inherit the container's location. */
- tmp = camel_mime_part_get_content_location(part);
- if (tmp == NULL) {
+ location = camel_mime_part_get_content_location(part);
+ if (location == NULL) {
if (((EMFormat *)efh)->base)
cid = camel_url_to_string(((EMFormat *)efh)->base, 0);
else
cid = g_strdup(((EMFormat *)efh)->part_id->str);
} else {
- if (strchr(tmp, ':') == NULL && ((EMFormat *)efh)->base != NULL) {
+ if (strchr(location, ':') == NULL && ((EMFormat *)efh)->base != NULL) {
CamelURL *uri;
- uri = camel_url_new_with_base(((EMFormat *)efh)->base, tmp);
+ uri = camel_url_new_with_base(((EMFormat *)efh)->base, location);
cid = camel_url_to_string(uri, 0);
camel_url_free(uri);
} else {
- cid = g_strdup(tmp);
+ cid = g_strdup(location);
}
}
@@ -1023,9 +1007,8 @@ efh_multipart_related(EMFormat *emf, Cam
CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
CamelMimePart *body_part, *display_part = NULL;
CamelContentType *content_type;
- const char *location, *start;
+ const char *start;
int i, nparts, partidlen, displayid = 0;
- CamelURL *base_save = NULL;
EMFormatPURI *puri;
struct _EMFormatHTMLJob *job;
@@ -1064,13 +1047,6 @@ efh_multipart_related(EMFormat *emf, Cam
return;
}
- /* stack of present location and pending uri's */
- location = camel_mime_part_get_content_location(part);
- if (location) {
- d(printf("setting content location %s\n", location));
- base_save = emf->base;
- emf->base = camel_url_new(location, NULL);
- }
em_format_push_level(emf);
partidlen = emf->part_id->len;
@@ -1098,11 +1074,6 @@ efh_multipart_related(EMFormat *emf, Cam
em_format_html_job_queue((EMFormatHTML *)emf, job);
em_format_pull_level(emf);
-
- if (location) {
- camel_url_free(emf->base);
- emf->base = base_save;
- }
}
static void
@@ -1331,6 +1302,9 @@ efh_format_timeout(struct _format_msg *m
mail_msg_free(m);
p->last_part = NULL;
} else {
+ /* FIXME: If we have a content-base header we should set/clear this here? */
+ /*gtk_html_set_base(efh->html, base);*/
+
/*hstream = gtk_html_begin(efh->html);*/
hstream = NULL;
m->estream = (EMHTMLStream *)em_html_stream_new(efh->html, hstream);
Index: mail/em-format.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format.c,v
retrieving revision 1.38.8.2
diff -u -p -r1.38.8.2 em-format.c
--- mail/em-format.c 24 Sep 2004 04:05:38 -0000 1.38.8.2
+++ mail/em-format.c 1 Nov 2004 05:10:23 -0000
@@ -521,10 +521,32 @@ void
em_format_part_as(EMFormat *emf, CamelStream *stream, CamelMimePart *part, const char *mime_type)
{
const EMFormatHandler *handle = NULL;
- const char *snoop_save = emf->snoop_mime_type;
+ const char *snoop_save = emf->snoop_mime_type, *tmp;
+ CamelURL *base_save = emf->base, *base = NULL;
+ char *basestr = NULL;
+
+ d(printf("format_part_as()\n"));
emf->snoop_mime_type = NULL;
+ /* RFC 2110, we keep track of content-base, and absolute content-location headers
+ This is actually only required for html, but, *shrug* */
+ tmp = camel_medium_get_header((CamelMedium *)part, "Content-Base");
+ if (tmp == NULL) {
+ tmp = camel_mime_part_get_content_location(part);
+ if (tmp && strchr(tmp, ':') == NULL)
+ tmp = NULL;
+ } else {
+ tmp = basestr = camel_header_location_decode(tmp);
+ }
+ printf("content-base is '%s'\n", tmp?tmp:"<unset>");
+ if (tmp
+ && (base = camel_url_new(tmp, NULL))) {
+ emf->base = base;
+ d(printf("Setting content base '%s'\n", tmp));
+ }
+ g_free(basestr);
+
if (mime_type != NULL) {
if (g_ascii_strcasecmp(mime_type, "application/octet-stream") == 0)
emf->snoop_mime_type = mime_type = em_utils_snoop_type(part);
@@ -537,8 +559,7 @@ em_format_part_as(EMFormat *emf, CamelSt
&& !em_format_is_attachment(emf, part)) {
d(printf("running handler for type '%s'\n", mime_type));
handle->handler(emf, stream, part, handle);
- emf->snoop_mime_type = snoop_save;
- return;
+ goto finish;
}
d(printf("this type is an attachment? '%s'\n", mime_type));
} else {
@@ -546,7 +567,12 @@ em_format_part_as(EMFormat *emf, CamelSt
}
((EMFormatClass *)G_OBJECT_GET_CLASS(emf))->format_attachment(emf, stream, part, mime_type, handle);
+finish:
+ emf->base = base_save;
emf->snoop_mime_type = snoop_save;
+
+ if (base)
+ camel_url_free(base);
}
void
@@ -1261,10 +1287,9 @@ emf_multipart_related(EMFormat *emf, Cam
CamelMultipart *mp = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)part);
CamelMimePart *body_part, *display_part = NULL;
CamelContentType *content_type;
- const char *location, *start;
+ const char *start;
int i, nparts, partidlen, displayid = 0;
char *oldpartid;
- CamelURL *base_save = NULL;
struct _EMFormatPURITree *ptree;
EMFormatPURI *puri, *purin;
@@ -1304,13 +1329,6 @@ emf_multipart_related(EMFormat *emf, Cam
return;
}
- /* stack of present location and pending uri's */
- location = camel_mime_part_get_content_location(part);
- if (location) {
- d(printf("setting content location %s\n", location));
- base_save = emf->base;
- emf->base = camel_url_new(location, NULL);
- }
em_format_push_level(emf);
oldpartid = g_strdup(emf->part_id->str);
@@ -1353,11 +1371,6 @@ emf_multipart_related(EMFormat *emf, Cam
g_free(oldpartid);
em_format_pull_level(emf);
-
- if (location) {
- camel_url_free(emf->base);
- emf->base = base_save;
- }
}
static void
Index: mail/em-format.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-format.h,v
retrieving revision 1.12
diff -u -p -r1.12 em-format.h
--- mail/em-format.h 10 Jul 2004 01:31:04 -0000 1.12
+++ mail/em-format.h 1 Nov 2004 05:10:23 -0000
@@ -117,7 +117,7 @@ struct _EMFormat {
EDList header_list; /* if empty, then all */
struct _CamelSession *session; /* session, used for authentication when required */
- struct _CamelURL *base; /* current location (base url) */
+ struct _CamelURL *base; /* content-base header or absolute content-location, for any part */
const char *snoop_mime_type; /* if we snooped an application/octet-stream type, what we snooped */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]