aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-10-08 02:19:34 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-10-08 02:19:34 +0800
commit988e56a5a96d2392511ba8282da18c6b68ed4e3c (patch)
tree72207d3d67d6868235e4197482852d3e8a8a824f
parent3b8bf37f68a98dd16412370aea4be4cf4f31aa2b (diff)
downloadgsoc2013-evolution-988e56a5a96d2392511ba8282da18c6b68ed4e3c.tar
gsoc2013-evolution-988e56a5a96d2392511ba8282da18c6b68ed4e3c.tar.gz
gsoc2013-evolution-988e56a5a96d2392511ba8282da18c6b68ed4e3c.tar.bz2
gsoc2013-evolution-988e56a5a96d2392511ba8282da18c6b68ed4e3c.tar.lz
gsoc2013-evolution-988e56a5a96d2392511ba8282da18c6b68ed4e3c.tar.xz
gsoc2013-evolution-988e56a5a96d2392511ba8282da18c6b68ed4e3c.tar.zst
gsoc2013-evolution-988e56a5a96d2392511ba8282da18c6b68ed4e3c.zip
Set content->rawtext to TRUE for text parts because the content is in its
2002-10-04 Jeffrey Stedfast <fejj@ximian.com> * e-msg-composer-attachment-bar.c (attach_to_multipart): Set content->rawtext to TRUE for text parts because the content is in its raw form (since we didn't know the charset when we created it). Also only write out the content-object to discover the best encoding, we don't want to include the headers of the MIME part. Second half of the fix for bug #31655. svn path=/trunk/; revision=18335
-rw-r--r--composer/ChangeLog9
-rw-r--r--composer/e-msg-composer-attachment-bar.c31
2 files changed, 33 insertions, 7 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index aae514d59c..f04c32fd74 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,12 @@
+2002-10-04 Jeffrey Stedfast <fejj@ximian.com>
+
+ * e-msg-composer-attachment-bar.c (attach_to_multipart): Set
+ content->rawtext to TRUE for text parts because the content is in
+ its raw form (since we didn't know the charset when we created
+ it). Also only write out the content-object to discover the best
+ encoding, we don't want to include the headers of the MIME
+ part. Second half of the fix for bug #31655.
+
2002-10-02 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer.c (get_file_content): Don't create a new file if
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index 98f73a7e00..1bf315ad08 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -739,10 +739,12 @@ attach_to_multipart (CamelMultipart *multipart,
const char *default_charset)
{
CamelContentType *content_type;
+ CamelDataWrapper *content;
content_type = camel_mime_part_get_content_type (attachment->body);
+ content = camel_medium_get_content_object (CAMEL_MEDIUM (attachment->body));
- if (!header_content_type_is (content_type, "multipart", "*")) {
+ if (!CAMEL_IS_MULTIPART (content)) {
if (header_content_type_is (content_type, "text", "*")) {
CamelMimePartEncodingType encoding;
CamelStreamFilter *filtered_stream;
@@ -750,18 +752,36 @@ attach_to_multipart (CamelMultipart *multipart,
CamelStream *stream;
char *type;
+ /* Let camel know that this text part was read in raw and thus is not in
+ * UTF-8 format so that when it writes this part out, it doesn't try to
+ * convert it from UTF-8 into the @default_charset charset. */
+ content->rawtext = TRUE;
+
stream = camel_stream_null_new ();
filtered_stream = camel_stream_filter_new_with_stream (stream);
bestenc = camel_mime_filter_bestenc_new (CAMEL_BESTENC_GET_ENCODING);
camel_stream_filter_add (filtered_stream, CAMEL_MIME_FILTER (bestenc));
camel_object_unref (CAMEL_OBJECT (stream));
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (attachment->body),
- CAMEL_STREAM (filtered_stream));
+ camel_data_wrapper_write_to_stream (content, CAMEL_STREAM (filtered_stream));
+ camel_object_unref (CAMEL_OBJECT (filtered_stream));
encoding = camel_mime_filter_bestenc_get_best_encoding (bestenc, CAMEL_BESTENC_8BIT);
camel_mime_part_set_encoding (attachment->body, encoding);
+ if (encoding == CAMEL_MIME_PART_ENCODING_7BIT) {
+ /* the text fits within us-ascii so this is safe */
+ /* FIXME: check that this isn't iso-2022-jp? */
+ default_charset = "us-ascii";
+ } else {
+ if (!default_charset)
+ default_charset = mail_config_get_default_charset ();
+
+ /* FIXME: We should really check that this fits within the
+ default_charset and if not find one that does and/or
+ allow the user to specify? */
+ }
+
/* looks kinda nasty, but this is how ya have to do it */
header_content_type_set_param (content_type, "charset", default_charset);
type = header_content_type_format (content_type);
@@ -769,8 +789,7 @@ attach_to_multipart (CamelMultipart *multipart,
g_free (type);
camel_object_unref (CAMEL_OBJECT (bestenc));
- camel_object_unref (CAMEL_OBJECT (filtered_stream));
- } else if (!header_content_type_is (content_type, "message", "*")) {
+ } else if (!CAMEL_IS_MIME_MESSAGE (content)) {
camel_mime_part_set_encoding (attachment->body,
CAMEL_MIME_PART_ENCODING_BASE64);
}
@@ -787,9 +806,7 @@ e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar,
EMsgComposerAttachmentBarPrivate *priv;
GList *p;
- g_return_if_fail (bar != NULL);
g_return_if_fail (E_IS_MSG_COMPOSER_ATTACHMENT_BAR (bar));
- g_return_if_fail (multipart != NULL);
g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
priv = bar->priv;