+2006-02-08 [colin] 2.0.0cvs34
+
+ * src/compose.c
+ * src/procmime.c
+ * src/procmime.h
+ Fix bug #905 (damaged attachment)
+ text files with raw \0's aren't really text files
+
2006-02-08 [colin] 2.0.0cvs33
* src/summaryview.c
( cvs diff -u -r 1.12.2.22 -r 1.12.2.23 src/prefs_template.c; ) > 2.0.0cvs31.patchset
( cvs diff -u -r 1.382.2.237 -r 1.382.2.238 src/compose.c; cvs diff -u -r 1.50.2.19 -r 1.50.2.20 src/compose.h; ) > 2.0.0cvs32.patchset
( cvs diff -u -r 1.395.2.166 -r 1.395.2.167 src/summaryview.c; ) > 2.0.0cvs33.patchset
+( cvs diff -u -r 1.382.2.238 -r 1.382.2.239 src/compose.c; cvs diff -u -r 1.49.2.70 -r 1.49.2.71 src/procmime.c; cvs diff -u -r 1.17.2.13 -r 1.17.2.14 src/procmime.h; ) > 2.0.0cvs34.patchset
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=33
+EXTRA_VERSION=34
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
gchar *size_text;
GtkListStore *store;
gchar *name;
+ gboolean has_binary = FALSE;
if (!is_file_exist(file)) {
g_warning("File %s doesn't exist\n", filename);
MsgInfo *msginfo;
MsgFlags flags = {0, 0};
- if (procmime_get_encoding_for_text_file(file) == ENC_7BIT)
+ if (procmime_get_encoding_for_text_file(file, &has_binary) == ENC_7BIT)
ainfo->encoding = ENC_7BIT;
else
ainfo->encoding = ENC_8BIT;
procmsg_msginfo_free(msginfo);
} else {
if (!g_ascii_strncasecmp(content_type, "text", 4))
- ainfo->encoding = procmime_get_encoding_for_text_file(file);
+ ainfo->encoding = procmime_get_encoding_for_text_file(file, &has_binary);
else
ainfo->encoding = ENC_BASE64;
name = g_path_get_basename(filename ? filename : file);
ainfo->encoding = ENC_BASE64;
} else if (!g_ascii_strncasecmp(ainfo->content_type, "text", 4))
ainfo->encoding =
- procmime_get_encoding_for_text_file(file);
+ procmime_get_encoding_for_text_file(file, &has_binary);
else
ainfo->encoding = ENC_BASE64;
name = g_path_get_basename(filename ? filename : file);
g_free(name);
}
- if (!strcmp(ainfo->content_type, "unknown")) {
+ if (!strcmp(ainfo->content_type, "unknown") || has_binary) {
g_free(ainfo->content_type);
ainfo->content_type = g_strdup("application/octet-stream");
}
return ENC_8BIT;
}
-EncodingType procmime_get_encoding_for_text_file(const gchar *file)
+EncodingType procmime_get_encoding_for_text_file(const gchar *file, gboolean *has_binary)
{
FILE *fp;
guchar buf[BUFFSIZE];
size_t octet_chars = 0;
size_t total_len = 0;
gfloat octet_percentage;
+ gboolean force_b64 = FALSE;
if ((fp = g_fopen(file, "rb")) == NULL) {
FILE_OP_ERROR(file, "fopen");
for (p = buf, i = 0; i < len; ++p, ++i) {
if (*p & 0x80)
++octet_chars;
+ if (*p == '\0') {
+ force_b64 = TRUE;
+ *has_binary = TRUE;
+ }
}
total_len += len;
}
"8bit chars: %d / %d (%f%%)\n", octet_chars, total_len,
100.0 * octet_percentage);
- if (octet_percentage > 0.20) {
+ if (octet_percentage > 0.20 || force_b64) {
debug_print("using BASE64\n");
return ENC_BASE64;
} else if (octet_chars > 0) {
GList *procmime_get_mime_type_list (void);
EncodingType procmime_get_encoding_for_charset (const gchar *charset);
-EncodingType procmime_get_encoding_for_text_file(const gchar *file);
+EncodingType procmime_get_encoding_for_text_file(const gchar *file,
+ gboolean *has_binary);
const gchar *procmime_get_encoding_str (EncodingType encoding);
MimeInfo *procmime_scan_file (const gchar *filename);
MimeInfo *procmime_scan_queue_file (const gchar *filename);