aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-format.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-04-30 05:28:00 +0800
committerDan Winship <danw@src.gnome.org>2000-04-30 05:28:00 +0800
commitd77a77c7e5d0d3aa9a8363a6a1ab7bfdd8235041 (patch)
tree688d9467e01c71c2afe8597b7c7719571e96377b /mail/mail-format.c
parent6942830c985d410264fff20734541b23dc62f64f (diff)
downloadgsoc2013-evolution-d77a77c7e5d0d3aa9a8363a6a1ab7bfdd8235041.tar.gz
gsoc2013-evolution-d77a77c7e5d0d3aa9a8363a6a1ab7bfdd8235041.tar.zst
gsoc2013-evolution-d77a77c7e5d0d3aa9a8363a6a1ab7bfdd8235041.zip
Handle clicks on "cid" URLs by popping up a "Save Attachment" dialog.
* mail-display.c (on_link_clicked): Handle clicks on "cid" URLs by popping up a "Save Attachment" dialog. * mail-format.c (get_cid): if the part has a Content-Disposition with a filename specified, record (a sanitized version of) that on the wrapper when creating the cid reference, so the "save attachment" code can use it later. (handle_mystery): fix a bug in the cid generation here. svn path=/trunk/; revision=2685
Diffstat (limited to 'mail/mail-format.c')
-rw-r--r--mail/mail-format.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/mail/mail-format.c b/mail/mail-format.c
index d10b74612b..6997f96158 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -115,6 +115,7 @@ get_cid (CamelMimePart *part, CamelMimeMessage *root)
CamelDataWrapper *wrapper =
camel_medium_get_content_object (CAMEL_MEDIUM (part));
char *cid;
+ const char *filename;
/* If we have a real Content-ID, use it. If we don't,
* make a (syntactically invalid) fake one.
@@ -125,6 +126,29 @@ get_cid (CamelMimePart *part, CamelMimeMessage *root)
cid = g_strdup_printf ("@@@%p", wrapper);
gtk_object_set_data (GTK_OBJECT (root), cid, wrapper);
+
+ /* Record the filename, in case the user wants to save this
+ * data later.
+ */
+ filename = camel_mime_part_get_filename (part);
+ if (filename) {
+ char *safe, *p;
+
+ safe = strrchr (filename, '/');
+ if (safe)
+ safe = g_strdup (safe + 1);
+ else
+ safe = g_strdup (filename);
+
+ for (p = safe; *p; p++) {
+ if (!isascii ((unsigned char)*p) ||
+ strchr (" /'\"`&();|<>${}!", *p))
+ *p = '_';
+ }
+
+ gtk_object_set_data (GTK_OBJECT (wrapper), "filename", safe);
+ }
+
return cid;
}
@@ -858,7 +882,7 @@ handle_mystery (CamelMimePart *part, CamelMimeMessage *root, GtkBox *box,
GMimeContentField *content_type;
mail_html_new (&html, &stream, root, TRUE);
- mail_html_write (html, stream, "<table><tr><td><a href=\"cid:%p\">"
+ mail_html_write (html, stream, "<table><tr><td><a href=\"cid:%s\">"
"<img src=\"x-gnome-icon:%s\"></a></td>"
"<td>%s<br>", get_cid (part, root), icon_name, id);