[geary/wip/attachment-filename-714549: 1/2] Replace slashes and NULs with _
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/attachment-filename-714549: 1/2] Replace slashes and NULs with _
- Date: Wed, 5 Mar 2014 23:06:52 +0000 (UTC)
commit d8ae1cf4673aa58d45b1e5a04e6e47b9c4f1abe4
Author: Charles Lindsay <chaz yorba org>
Date: Wed Mar 5 12:09:05 2014 -0800
Replace slashes and NULs with _
src/engine/imap-db/imap-db-folder.vala | 2 +-
src/engine/rfc822/rfc822-message.vala | 2 +-
src/engine/rfc822/rfc822-utils.vala | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-folder.vala b/src/engine/imap-db/imap-db-folder.vala
index df244f3..bc9370c 100644
--- a/src/engine/imap-db/imap-db-folder.vala
+++ b/src/engine/imap-db/imap-db-folder.vala
@@ -1898,7 +1898,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
foreach (GMime.Part attachment in attachments) {
string mime_type = attachment.get_content_type().to_string();
string disposition = attachment.get_disposition();
- string filename = RFC822.Utils.get_attachment_filename(attachment);
+ string filename = RFC822.Utils.get_clean_attachment_filename(attachment);
// Convert the attachment content into a usable ByteArray.
GMime.DataWrapper attachment_data = attachment.get_content_object();
diff --git a/src/engine/rfc822/rfc822-message.vala b/src/engine/rfc822/rfc822-message.vala
index 3cfc1e6..aa32c6b 100644
--- a/src/engine/rfc822/rfc822-message.vala
+++ b/src/engine/rfc822/rfc822-message.vala
@@ -512,7 +512,7 @@ public class Geary.RFC822.Message : BaseObject {
return false;
// Hand off to the replacer for processing
- string? replaced_part = replacer(RFC822.Utils.get_attachment_filename(part), content_type,
+ string? replaced_part = replacer(RFC822.Utils.get_clean_attachment_filename(part), content_type,
disposition, mime_part_to_memory_buffer(part));
if (replaced_part != null)
body = replaced_part;
diff --git a/src/engine/rfc822/rfc822-utils.vala b/src/engine/rfc822/rfc822-utils.vala
index 747cc4f..ad96433 100644
--- a/src/engine/rfc822/rfc822-utils.vala
+++ b/src/engine/rfc822/rfc822-utils.vala
@@ -320,12 +320,13 @@ public GMime.ContentEncoding get_best_content_encoding(GMime.Stream stream,
return encoding;
}
-public string get_attachment_filename(GMime.Part part) {
+public string get_clean_attachment_filename(GMime.Part part) {
string? filename = part.get_filename();
if (String.is_empty(filename)) {
/// Placeholder filename for attachments with no filename.
filename = _("none");
}
+ filename = filename.replace("/", "_").replace("\0", "_");
return filename;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]