From 6cc33a7de2bafb4f80befee54d898f8e4319362a Mon Sep 17 00:00:00 2001 From: ty221 Date: Sat, 3 Jan 2015 23:34:52 +0100 Subject: [PATCH 1/2] Fixed issue #281 --- lib/sup/modes/edit_message_mode.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/sup/modes/edit_message_mode.rb b/lib/sup/modes/edit_message_mode.rb index 39d7b36b7..50bd44aa1 100644 --- a/lib/sup/modes/edit_message_mode.rb +++ b/lib/sup/modes/edit_message_mode.rb @@ -342,6 +342,14 @@ def unsaved?; edited? end def attach_file fn = BufferManager.ask_for_filename :attachment, "File name (enter for browser): " return unless fn + + # This code is being used to backslash special characters in file name + fn.gsub! "\\", "\\\\\\\\" + fn.gsub! ' ', '\ ' + fn.gsub! '"', '\\\\"' + fn.gsub! "'", "\\\\'" + # End of this code + if HookManager.enabled? "check-attachment" reason = HookManager.run("check-attachment", :filename => fn) if reason From 1561444a0133277d8da07f6d1fed0df6c0e5884d Mon Sep 17 00:00:00 2001 From: ty221 Date: Sun, 4 Jan 2015 10:15:40 +0100 Subject: [PATCH 2/2] Backslashing improvments --- lib/sup/modes/edit_message_mode.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/sup/modes/edit_message_mode.rb b/lib/sup/modes/edit_message_mode.rb index 50bd44aa1..a1577dc2e 100644 --- a/lib/sup/modes/edit_message_mode.rb +++ b/lib/sup/modes/edit_message_mode.rb @@ -343,13 +343,6 @@ def attach_file fn = BufferManager.ask_for_filename :attachment, "File name (enter for browser): " return unless fn - # This code is being used to backslash special characters in file name - fn.gsub! "\\", "\\\\\\\\" - fn.gsub! ' ', '\ ' - fn.gsub! '"', '\\\\"' - fn.gsub! "'", "\\\\'" - # End of this code - if HookManager.enabled? "check-attachment" reason = HookManager.run("check-attachment", :filename => fn) if reason @@ -357,6 +350,12 @@ def attach_file end end begin + # This code is being used to backslash special characters in file name + fn.gsub! "\\", "\\\\\\\\" + fn.gsub! '*', '\*' + fn.gsub! '?', '\?' + fn.gsub! "[", "\\[" + # End of this code Dir[fn].each do |f| @attachments << RMail::Message.make_file_attachment(f) @attachment_names << f @@ -383,7 +382,7 @@ def rerun_crypto_selector_hook HookManager.run "crypto-mode", :header => @header, :body => @body, :crypto_selector => @crypto_selector end end - + def mime_encode string string = [string].pack('M') # basic quoted-printable string.gsub!(/=\n/,'') # .. remove trailing newline