Commit notifications for all Sup repositories
 help / color / mirror / Atom feed
From: Dan Callaghan <dan@bl2.djc.id.au>
To: sup-commits@supmua.dev
Subject: [sup.git] 02/03: strip out slashes in attachment filenames when saving to dir
Date: Fri, 20 Nov 2026 21:37:59 +1100	[thread overview]
Message-ID: <20261120103758.22C0C2D09E6@bl2.djc.id.au> (raw)
In-Reply-To: <179517107783.237609.3020024330765005481@bl2.djc.id.au>

New commit on branch develop:
https://supmua.dev/git/sup/commit/96907538b0ecdb9c23ec6dc73dfda9ff0f5538d6.html

commit 96907538b0ecdb9c23ec6dc73dfda9ff0f5538d6
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Fri Nov 20 19:59:27 2026 +1100

    strip out slashes in attachment filenames when saving to dir
    
    Commit 2caccbb02f did this already for the default suggested filename,
    and when saving all attachments to disk, but missed the case where the
    user chooses a specific attachment and then gives a directory to save
    into.
---
 lib/sup/modes/thread_view_mode.rb  |  2 +-
 test/unit/test_thread_view_mode.rb | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/sup/modes/thread_view_mode.rb b/lib/sup/modes/thread_view_mode.rb
index 0de55b6f..33ee39e1 100644
--- a/lib/sup/modes/thread_view_mode.rb
+++ b/lib/sup/modes/thread_view_mode.rb
@@ -397,7 +397,7 @@ EOS
 
       # if user selects directory use file name from message
       if fn and File.directory? fn
-        fn = File.join(fn, chunk.filename)
+        fn = File.join(fn, chunk.filesafe_filename)
       end
 
       save_to_file(fn) { |f| f.print chunk.raw_content } if fn
diff --git a/test/unit/test_thread_view_mode.rb b/test/unit/test_thread_view_mode.rb
index bcc5f9ef..4c8ae839 100644
--- a/test/unit/test_thread_view_mode.rb
+++ b/test/unit/test_thread_view_mode.rb
@@ -68,6 +68,18 @@ class TestThreadViewMode < Minitest::Test
     expected_path = File.join destdir, "sup_.travis.yml"
     assert File.exist? expected_path
     assert_equal 260, File.size(expected_path)
+
+    ## Scroll to the attachment and save it to a directory.
+    destdir = File.join(@path, "saved2")
+    Dir.mkdir destdir
+    stub(BufferManager.instance).ask(:filename, "Save attachment to file or directory: ", "#{ENV["HOME"]}/sup_.travis.yml") { destdir }
+    stub(BufferManager.instance).flash("Successfully wrote #{destdir}/sup_.travis.yml.")
+    assert_equal "x Attachment: sup/.travis.yml (text/x-yaml; 260B)", mode[10][0][1]
+    mode.send :set_cursor_pos, 10
+    mode.save_to_disk
+    expected_path = File.join destdir, "sup_.travis.yml"
+    assert File.exist? expected_path
+    assert_equal 260, File.size(expected_path)
   end
 end
 

  parent reply	other threads:[~2026-11-20 10:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 10:37 [sup.git] branch develop updated (154ff507 -> ab44ffd7) Dan Callaghan
2026-11-20 10:37 ` [sup.git] 01/03: tests: add thread-view-mode test for attachment filename escaping Dan Callaghan
2026-11-20 10:37 ` Dan Callaghan [this message]
2026-11-20 10:38 ` [sup.git] 03/03: strip out slashes in attachment filenames for fallback text-view mode Dan Callaghan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120103758.22C0C2D09E6@bl2.djc.id.au \
    --to=dan@bl2.djc.id.au \
    --cc=djc@djc.id.au \
    --cc=sup-commits@supmua.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox