* [sup.git] branch develop updated (ce27c933 -> 53f07beb)
@ 2026-11-28 6:13 Dan Callaghan
2026-11-28 6:13 ` [sup.git] 01/08: delete dead report_broken_sources method Dan Callaghan
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
Pushed branch develop:
from ce27c933 prepare for next release
new 192c6873 delete dead report_broken_sources method
new 89ac0a7f sup-sync-back-maildir: remove broken negative short options
new 9bfe7ee6 show both raw and encoded sizes of attachments
new 44806477 shell escape bounce destination addresses
new 846f5d83 call setlocale() through ncurses bindings instead of fiddle
new 07f79743 use libmagic to detect attachment MIME types
new f096837a clean up directory traversal in Maildir#poll
new 53f07beb bring back sup-recover-sources from the dead
Summary of changes:
Manifest.txt | 24 +++++-
bin/sup | 13 +--
bin/sup-recover-sources | 118 +++++++++++++--------------
bin/sup-sync-back-maildir | 8 +-
contrib/nix/Gemfile | 3 +-
contrib/nix/Gemfile.lock | 10 +--
contrib/nix/gemset.nix | 42 +++-------
contrib/nix/ruby2.4-Gemfile.lock | 9 +-
contrib/nix/ruby2.4-gemset.nix | 42 +++-------
contrib/nix/ruby2.4-shell.nix | 5 +-
contrib/nix/ruby2.5-Gemfile.lock | 9 +-
contrib/nix/ruby2.5-gemset.nix | 42 +++-------
contrib/nix/ruby2.5-shell.nix | 5 +-
contrib/nix/ruby2.6-Gemfile.lock | 9 +-
contrib/nix/ruby2.6-gemset.nix | 42 +++-------
contrib/nix/ruby2.6-shell.nix | 5 +-
contrib/nix/ruby2.7-Gemfile.lock | 9 +-
contrib/nix/ruby2.7-gemset.nix | 42 +++-------
contrib/nix/ruby2.7-shell.nix | 6 ++
contrib/nix/ruby3.0-Gemfile.lock | 9 +-
contrib/nix/ruby3.0-gemset.nix | 42 +++-------
contrib/nix/ruby3.0-shell.nix | 6 ++
contrib/nix/ruby3.1-Gemfile.lock | 11 +--
contrib/nix/ruby3.1-gemset.nix | 52 +++---------
contrib/nix/ruby3.1-shell.nix | 6 ++
contrib/nix/ruby3.2-Gemfile.lock | 11 +--
contrib/nix/ruby3.2-gemset.nix | 52 +++---------
contrib/nix/ruby3.2-shell.nix | 6 ++
contrib/nix/ruby3.3-shell.nix | 6 ++
contrib/nix/ruby3.4-shell.nix | 4 +
contrib/nix/ruby4.0-shell.nix | 4 +
lib/sup.rb | 52 +-----------
lib/sup/index.rb | 9 +-
lib/sup/maildir.rb | 14 +++-
lib/sup/mbox.rb | 16 ++++
lib/sup/message_chunks.rb | 9 +-
lib/sup/modes/edit_message_mode.rb | 14 +++-
lib/sup/modes/thread_view_mode.rb | 2 +-
lib/sup/source.rb | 6 ++
lib/sup/util.rb | 21 +++--
lib/sup/util/locale_fiddler.rb | 24 ------
sup.gemspec | 3 +-
test/fixtures/attachments/Cargo.toml | 4 +
test/fixtures/attachments/Dockerfile | 3 +
test/fixtures/attachments/Hello.pm | 7 ++
test/fixtures/attachments/Makefile | 2 +
test/fixtures/attachments/board.dtb | Bin 0 -> 145 bytes
test/fixtures/attachments/board.dts | 6 ++
test/fixtures/attachments/component.wasm | Bin 0 -> 8 bytes
test/fixtures/attachments/configure | 2 +
test/fixtures/attachments/cp1251.txt | 1 +
test/fixtures/attachments/firmware.hex | 2 +
test/fixtures/attachments/git-format.patch | 23 ++++++
test/fixtures/attachments/go.mod | 3 +
test/fixtures/attachments/hello | Bin 0 -> 132 bytes
test/fixtures/attachments/hello.c | 8 ++
test/fixtures/attachments/hello.py | 2 +
test/fixtures/attachments/koi8.txt | 1 +
test/fixtures/attachments/main.rs | 3 +
test/fixtures/attachments/main.ts | 2 +
test/fixtures/attachments/minimal.pdf | 14 ++++
test/fixtures/attachments/module.wasm | Bin 0 -> 13 bytes
test/fixtures/attachments/traditional.patch | 9 ++
test/integration/test_sup-recover-sources.rb | 68 +++++++++++++++
test/test_message.rb | 12 ++-
test/unit/test_edit_message_mode.rb | 12 ++-
test/unit/test_locale_fiddler.rb | 15 ----
test/unit/test_rmail_message.rb | 54 +++++++++++-
68 files changed, 545 insertions(+), 530 deletions(-)
delete mode 100644 lib/sup/util/locale_fiddler.rb
create mode 100644 test/fixtures/attachments/Cargo.toml
create mode 100644 test/fixtures/attachments/Dockerfile
create mode 100644 test/fixtures/attachments/Hello.pm
create mode 100644 test/fixtures/attachments/Makefile
create mode 100644 test/fixtures/attachments/board.dtb
create mode 100644 test/fixtures/attachments/board.dts
create mode 100644 test/fixtures/attachments/component.wasm
create mode 100755 test/fixtures/attachments/configure
create mode 100644 test/fixtures/attachments/cp1251.txt
create mode 100644 test/fixtures/attachments/firmware.hex
create mode 100644 test/fixtures/attachments/git-format.patch
create mode 100644 test/fixtures/attachments/go.mod
create mode 100755 test/fixtures/attachments/hello
create mode 100644 test/fixtures/attachments/hello.c
create mode 100644 test/fixtures/attachments/hello.py
create mode 100644 test/fixtures/attachments/koi8.txt
create mode 100644 test/fixtures/attachments/main.rs
create mode 100644 test/fixtures/attachments/main.ts
create mode 100644 test/fixtures/attachments/minimal.pdf
create mode 100644 test/fixtures/attachments/module.wasm
create mode 100644 test/fixtures/attachments/traditional.patch
create mode 100644 test/integration/test_sup-recover-sources.rb
delete mode 100644 test/unit/test_locale_fiddler.rb
^ permalink raw reply [flat|nested] 9+ messages in thread
* [sup.git] 01/08: delete dead report_broken_sources method
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
2026-11-28 6:13 ` [sup.git] 02/08: sup-sync-back-maildir: remove broken negative short options Dan Callaghan
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/192c6873dbf8d16cdea849a601cbe2614743ff8a.html
commit 192c6873dbf8d16cdea849a601cbe2614743ff8a
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Nov 21 10:52:57 2026 +1100
delete dead report_broken_sources method
It has been unused since commit 7edbb7ee67.
---
lib/sup.rb | 52 +---------------------------------------------------
1 file changed, 1 insertion(+), 51 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
index 82f465c5..f303aaac 100644
--- a/lib/sup.rb
+++ b/lib/sup.rb
@@ -262,56 +262,6 @@ EOS
$config = nil
end
- ## not really a good place for this, so I'll just dump it here.
- ##
- ## a source error is either a FatalSourceError or an OutOfSyncSourceError.
- ## the superclass SourceError is just a generic.
- def report_broken_sources opts={}
- return unless BufferManager.instantiated?
-
- broken_sources = SourceManager.sources.select { |s| s.error.is_a? FatalSourceError }
- unless broken_sources.empty?
- BufferManager.spawn_unless_exists("Broken source notification for #{broken_sources.join(',')}", opts) do
- TextMode.new(<<EOM)
-Source error notification
--------------------------
-
-Hi there. It looks like one or more message sources is reporting
-errors. Until this is corrected, messages from these sources cannot
-be viewed, and new messages will not be detected.
-
-#{broken_sources.map { |s| "Source: " + s.to_s + "\n Error: " + s.error.message.wrap(70).join("\n ")}.join("\n\n")}
-EOM
-#' stupid ruby-mode
- end
- end
-
- desynced_sources = SourceManager.sources.select { |s| s.error.is_a? OutOfSyncSourceError }
- unless desynced_sources.empty?
- BufferManager.spawn_unless_exists("Out-of-sync source notification for #{broken_sources.join(',')}", opts) do
- TextMode.new(<<EOM)
-Out-of-sync source notification
--------------------------------
-
-Hi there. It looks like one or more sources has fallen out of sync
-with my index. This can happen when you modify these sources with
-other email clients. (Sorry, I don't play well with others.)
-
-Until this is corrected, messages from these sources cannot be viewed,
-and new messages will not be detected. Luckily, this is easy to correct!
-
-#{desynced_sources.map do |s|
- "Source: " + s.to_s +
- "\n Error: " + s.error.message.wrap(70).join("\n ") +
- "\n Fix: sup-sync --changed #{s.to_s}"
- end}
-EOM
-#' stupid ruby-mode
- end
- end
- end
-
-
## set up default configuration file
def load_config filename
default_config = {
@@ -381,7 +331,7 @@ EOM
end
module_function :save_yaml_obj, :load_yaml_obj, :start, :finish,
- :report_broken_sources, :load_config, :managers,
+ :load_config, :managers,
:check_syncback_settings
end
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [sup.git] 02/08: sup-sync-back-maildir: remove broken negative short options
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
2026-11-28 6:13 ` [sup.git] 01/08: delete dead report_broken_sources method Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
2026-11-28 6:13 ` [sup.git] 03/08: show both raw and encoded sizes of attachments Dan Callaghan
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/89ac0a7fd8a9da8cc5627b6423ea144bd0962f08.html
commit 89ac0a7fd8a9da8cc5627b6423ea144bd0962f08
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Nov 21 11:24:14 2026 +1100
sup-sync-back-maildir: remove broken negative short options
Optimist treats boolean flags whose names begin with no_ specially:
https://github.com/ManageIQ/optimist/blob/v3.2.1/FAQ.txt#L86
For such options the short flag does not have the expected effect (it
sets the value to false not true) and there does not seem to be any
reasonable way to fix it. Just delete the short flag for these options.
---
bin/sup-sync-back-maildir | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/bin/sup-sync-back-maildir b/bin/sup-sync-back-maildir
index 1eeb9a34..5199806a 100755
--- a/bin/sup-sync-back-maildir
+++ b/bin/sup-sync-back-maildir
@@ -22,8 +22,8 @@ have an e-mail file like this: foo_bar:2,FRS (flags are favorite,
replied, seen) and its Xapian entry has labels 'starred', the merge
operation will add the 'replied' label to the Xapian entry.
-If you choose not to merge (-m) you will lose information ('replied'), and in
-the previous example the file will be renamed to foo_bar:2,FS.
+If you choose not to merge (--no-merge) you will lose information ('replied'),
+and in the previous example the file will be renamed to foo_bar:2,FS.
Running this script is *strongly* recommended when setting the
"sync_back_to_maildir" option from false to true in config.yaml or changing the
@@ -38,8 +38,8 @@ sync back using the configuration parameter sync_back = false in sources.yaml.
Options include:
EOS
- opt :no_confirm, "Don't ask for confirmation before synchronizing", :default => false, :short => "n"
- opt :no_merge, "Don't merge new supported Maildir flags (R and P)", :default => false, :short => "m"
+ opt :no_confirm, "Don't ask for confirmation before synchronizing", :default => false, :short => :none
+ opt :no_merge, "Don't merge new supported Maildir flags (R and P)", :default => false, :short => :none
opt :list_sources, "List your Maildir sources and exit", :default => false, :short => "l"
opt :unusual_sources_too, "Sync unusual sources too if no specific source information is given", :default => false, :short => "u"
end
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [sup.git] 03/08: show both raw and encoded sizes of attachments
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
2026-11-28 6:13 ` [sup.git] 01/08: delete dead report_broken_sources method Dan Callaghan
2026-11-28 6:13 ` [sup.git] 02/08: sup-sync-back-maildir: remove broken negative short options Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
2026-11-28 6:13 ` [sup.git] 04/08: shell escape bounce destination addresses Dan Callaghan
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/9bfe7ee6169eb3e5c722112340291ca5a7ca73a7.html
commit 9bfe7ee6169eb3e5c722112340291ca5a7ca73a7
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Nov 21 14:50:28 2026 +1100
show both raw and encoded sizes of attachments
Also make the attachment line in edit-message-mode consistent with
thread-view-mode. Both will now display the content type, decoded byte
size, and encoded byte size (if it is different) in human friendly
units.
Fixes #457.
---
lib/sup/message_chunks.rb | 9 ++++++++-
lib/sup/modes/edit_message_mode.rb | 14 +++++++++++++-
test/test_message.rb | 12 ++++++++----
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/lib/sup/message_chunks.rb b/lib/sup/message_chunks.rb
index e9055d86..60ed47b6 100644
--- a/lib/sup/message_chunks.rb
+++ b/lib/sup/message_chunks.rb
@@ -95,6 +95,7 @@ EOS
@filename = filename
@quotable = false # changed to true if we can parse it through the
# mime-decode hook, or if it's plain text
+ @encoded_content = encoded_content
@raw_content =
if encoded_content.body
encoded_content.decode
@@ -141,7 +142,13 @@ EOS
if expandable?
"Attachment: #{filename} (#{lines.length} lines)"
else
- "Attachment: #{filename} (#{content_type}; #{@raw_content.size.to_human_size})"
+ raw_size = @raw_content.bytesize.to_human_size
+ encoded_size = @encoded_content.body.bytesize.to_human_size
+ if encoded_size == raw_size
+ "Attachment: #{filename} (#{content_type}; #{raw_size})"
+ else
+ "Attachment: #{filename} (#{content_type}; #{raw_size}; #{encoded_size} encoded)"
+ end
end
end
def safe_filename; Shellwords.escape(@filename).gsub("/", "_") end
diff --git a/lib/sup/modes/edit_message_mode.rb b/lib/sup/modes/edit_message_mode.rb
index aa3f4177..2cc8adaa 100644
--- a/lib/sup/modes/edit_message_mode.rb
+++ b/lib/sup/modes/edit_message_mode.rb
@@ -457,7 +457,19 @@ protected
unless @attachments.empty?
@text += [""]
@attachment_lines_offset = @text.length
- @text += (0 ... @attachments.size).map { |i| [[:attachment_color, "+ Attachment: #{@attachment_names[i]} (#{@attachments[i].body.size.to_human_size})"]] }
+ @text += (0 ... @attachments.size).map do |i|
+ name = @attachment_names[i]
+ content_type = @attachments[i].header.content_type
+ raw_size = @attachments[i].decode.bytesize.to_human_size
+ encoded_size = @attachments[i].body.bytesize.to_human_size
+ line =
+ if encoded_size == raw_size
+ "+ Attachment: #{name} (#{content_type}; #{raw_size})"
+ else
+ "+ Attachment: #{name} (#{content_type}; #{raw_size}; #{encoded_size} encoded)"
+ end
+ [[:attachment_color, line]]
+ end
end
end
diff --git a/test/test_message.rb b/test/test_message.rb
index 95b7378a..598aec31 100644
--- a/test/test_message.rb
+++ b/test/test_message.rb
@@ -112,13 +112,15 @@ class TestMessage < Minitest::Test
assert_equal(4, chunks.length)
assert(chunks[0].is_a? Redwood::Chunk::Quote)
+ assert_equal ["Excerpts from Fake Sender's message of Sun Dec 09 21:48:19 +0200 2007:",
+ "> Test message!"],
+ chunks[0].lines
assert(chunks[1].is_a? Redwood::Chunk::Text)
+ assert_equal ["", "Thanks for the message!"], chunks[1].lines
assert(chunks[2].is_a? Redwood::Chunk::Attachment)
+ assert_equal "Attachment: HACKING (application/octet-stream; 627B; 850B encoded)", chunks[2].patina_text
assert(chunks[3].is_a? Redwood::Chunk::Attachment)
-
- # further testing of chunks will happen in test_message_chunks.rb
- # (possibly not yet implemented)
-
+ assert_equal "Attachment: Manifest.txt (13 lines)", chunks[3].patina_text
end
def test_broken_message_1
@@ -170,6 +172,8 @@ class TestMessage < Minitest::Test
assert_equal(1, chunks.length)
assert(chunks[0].is_a? Redwood::Chunk::Attachment)
+ assert_match(/^Attachment: sup-attachment-\d+-\d+\.html \(text\/html; 635B; 661B encoded\)$/,
+ chunks[0].patina_text)
end
def test_text_attachment_decoding
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [sup.git] 04/08: shell escape bounce destination addresses
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
` (2 preceding siblings ...)
2026-11-28 6:13 ` [sup.git] 03/08: show both raw and encoded sizes of attachments Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
2026-11-28 6:13 ` [sup.git] 05/08: call setlocale() through ncurses bindings instead of fiddle Dan Callaghan
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/4480647703939e89d1cd98ff7eeb5c6eec3a7948.html
commit 4480647703939e89d1cd98ff7eeb5c6eec3a7948
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Nov 21 17:02:22 2026 +1100
shell escape bounce destination addresses
---
lib/sup/modes/thread_view_mode.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/sup/modes/thread_view_mode.rb b/lib/sup/modes/thread_view_mode.rb
index 0db03f4f..acbaf9ce 100644
--- a/lib/sup/modes/thread_view_mode.rb
+++ b/lib/sup/modes/thread_view_mode.rb
@@ -267,7 +267,7 @@ EOS
cmd = case (hookcmd = HookManager.run "bounce-command", :from => m.from, :to => to)
when nil, /^$/ then defcmd
else hookcmd
- end + ' ' + to.map { |t| t.email }.join(' ')
+ end + ' ' + to.map { |t| Shellwords.escape t.email }.join(' ')
bt = to.size > 1 ? "#{to.size} recipients" : to[0].to_s
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [sup.git] 05/08: call setlocale() through ncurses bindings instead of fiddle
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
` (3 preceding siblings ...)
2026-11-28 6:13 ` [sup.git] 04/08: shell escape bounce destination addresses Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
2026-11-28 6:13 ` [sup.git] 06/08: use libmagic to detect attachment MIME types Dan Callaghan
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/846f5d83619572e570304b88c57a8e69decfd495.html
commit 846f5d83619572e570304b88c57a8e69decfd495
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Nov 21 17:17:47 2026 +1100
call setlocale() through ncurses bindings instead of fiddle
The approach of calling setlocale() via fiddle was problematic for a few
reasons. It hardcoded 6 for LC_ALL but this is only true on glibc, on
other platforms 6 is a different constant. And on many platforms Sup
would choose the wrong libc name or not know which name to use, see for
example PR #595.
It turns out ncurses worked fine anyway because Ruby since 1.9 already
calls setlocale(LC_CTYPE, "") at startup, which is enough for ncurses to
enable wide character support. So LocaleFiddler was not really needed on
Ruby 1.9 and above. However the call to setlocale() is still important
for gpgme message localisation. And it is expected that the main program
should call setlocale() for any libraries which use locale-aware
functions (like ncurses and gpgme do) so it's still the "proper" thing
to do.
The ncursesw gem already binds setlocale() so just call that instead of
using fiddle.
---
Manifest.txt | 2 --
bin/sup | 13 +------------
contrib/nix/Gemfile | 1 -
contrib/nix/Gemfile.lock | 1 -
contrib/nix/ruby2.4-Gemfile.lock | 2 --
contrib/nix/ruby2.4-gemset.nix | 10 ----------
contrib/nix/ruby2.4-shell.nix | 3 ---
contrib/nix/ruby2.5-Gemfile.lock | 2 --
contrib/nix/ruby2.5-gemset.nix | 10 ----------
contrib/nix/ruby2.5-shell.nix | 3 ---
contrib/nix/ruby2.6-Gemfile.lock | 2 --
contrib/nix/ruby2.6-gemset.nix | 10 ----------
contrib/nix/ruby2.6-shell.nix | 3 ---
contrib/nix/ruby2.7-Gemfile.lock | 2 --
contrib/nix/ruby2.7-gemset.nix | 10 ----------
contrib/nix/ruby3.0-Gemfile.lock | 2 --
contrib/nix/ruby3.0-gemset.nix | 10 ----------
contrib/nix/ruby3.1-Gemfile.lock | 2 --
contrib/nix/ruby3.1-gemset.nix | 10 ----------
contrib/nix/ruby3.2-Gemfile.lock | 2 --
contrib/nix/ruby3.2-gemset.nix | 10 ----------
lib/sup/util/locale_fiddler.rb | 24 ------------------------
sup.gemspec | 1 -
test/unit/test_locale_fiddler.rb | 15 ---------------
24 files changed, 1 insertion(+), 149 deletions(-)
diff --git a/Manifest.txt b/Manifest.txt
index a523f1c5..03b5678e 100644
--- a/Manifest.txt
+++ b/Manifest.txt
@@ -131,7 +131,6 @@ lib/sup/undo.rb
lib/sup/update.rb
lib/sup/util.rb
lib/sup/util/axe.rb
-lib/sup/util/locale_fiddler.rb
lib/sup/util/ncurses.rb
lib/sup/util/path.rb
lib/sup/util/query.rb
@@ -191,7 +190,6 @@ test/unit/test_edit_message_mode.rb
test/unit/test_horizontal_selector.rb
test/unit/test_index.rb
test/unit/test_line_cursor_mode.rb
-test/unit/test_locale_fiddler.rb
test/unit/test_maildir.rb
test/unit/test_person.rb
test/unit/test_rmail_message.rb
diff --git a/bin/sup b/bin/sup
index b8c0ef22..3ba9b356 100755
--- a/bin/sup
+++ b/bin/sup
@@ -6,7 +6,6 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'ncursesw'
require 'sup/util/ncurses'
-require 'sup/util/locale_fiddler'
require 'sup/util/axe'
no_gpgme = false
@@ -106,17 +105,7 @@ end
require 'rbconfig'
-unless RbConfig::CONFIG['arch'] =~ /openbsd/
- debug "dynamically loading setlocale()"
- begin
- class LibC; extend LocaleFiddler; end
- debug "setting locale..."
- LibC.setlocale(6, "")
- rescue RuntimeError => e
- warn "cannot dlload setlocale(); ncurses wide character support probably broken."
- warn "dlload error was #{e.class}: #{e.message}"
- end
-end
+Ncurses.setlocale Ncurses::LC_ALL, ""
def start_cursing
Ncurses.initscr
diff --git a/contrib/nix/Gemfile b/contrib/nix/Gemfile
index 00810768..6afd5a2f 100644
--- a/contrib/nix/Gemfile
+++ b/contrib/nix/Gemfile
@@ -13,7 +13,6 @@ gem "unicode", "~> 0.4.4"
gem "unicode-display_width"
gem "string-scrub" if /^2\.0\./ =~ RUBY_VERSION
gem "benchmark"
-gem "fiddle"
gem "bundler", ">= 1.3", "< 3"
gem "rake"
diff --git a/contrib/nix/Gemfile.lock b/contrib/nix/Gemfile.lock
index 107d22e0..10ad08a0 100644
--- a/contrib/nix/Gemfile.lock
+++ b/contrib/nix/Gemfile.lock
@@ -86,7 +86,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby2.4-Gemfile.lock b/contrib/nix/ruby2.4-Gemfile.lock
index 81bef91a..99130e4e 100644
--- a/contrib/nix/ruby2.4-Gemfile.lock
+++ b/contrib/nix/ruby2.4-Gemfile.lock
@@ -5,7 +5,6 @@ GEM
benchmark (0.4.0)
chronic (0.10.2)
coderay (1.1.3)
- fiddle (1.0.9)
gpgme (2.0.20)
mini_portile2 (~> 2.3)
highline (2.0.3)
@@ -63,7 +62,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby2.4-gemset.nix b/contrib/nix/ruby2.4-gemset.nix
index f596ed0d..0e550914 100644
--- a/contrib/nix/ruby2.4-gemset.nix
+++ b/contrib/nix/ruby2.4-gemset.nix
@@ -39,16 +39,6 @@
};
version = "1.1.3";
};
- fiddle = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1d2y2qh6xml4w6p15kaz1v2ryb8p3nm6yy5x5mfygdrxgpsc63rd";
- type = "gem";
- };
- version = "1.0.9";
- };
gpgme = {
dependencies = ["mini_portile2"];
groups = ["default"];
diff --git a/contrib/nix/ruby2.4-shell.nix b/contrib/nix/ruby2.4-shell.nix
index 26a479f4..3663b55a 100644
--- a/contrib/nix/ruby2.4-shell.nix
+++ b/contrib/nix/ruby2.4-shell.nix
@@ -11,9 +11,6 @@ let
lockfile = ./ruby2.4-Gemfile.lock;
gemset = ./ruby2.4-gemset.nix;
gemConfig = pkgs.defaultGemConfig // {
- fiddle = attrs: {
- buildInputs = [ pkgs.libffi ];
- };
# Workaround: remove rake from nativeBuildInputs, otherwise it causes
# xapian-bindings to build against the default Ruby version
# instead of our chosen version.
diff --git a/contrib/nix/ruby2.5-Gemfile.lock b/contrib/nix/ruby2.5-Gemfile.lock
index cb527e6f..974b47d2 100644
--- a/contrib/nix/ruby2.5-Gemfile.lock
+++ b/contrib/nix/ruby2.5-Gemfile.lock
@@ -5,7 +5,6 @@ GEM
benchmark (0.4.0)
chronic (0.10.2)
coderay (1.1.3)
- fiddle (1.0.9)
gpgme (2.0.20)
mini_portile2 (~> 2.3)
highline (2.0.3)
@@ -63,7 +62,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby2.5-gemset.nix b/contrib/nix/ruby2.5-gemset.nix
index 184f3ed6..277912a3 100644
--- a/contrib/nix/ruby2.5-gemset.nix
+++ b/contrib/nix/ruby2.5-gemset.nix
@@ -39,16 +39,6 @@
};
version = "1.1.3";
};
- fiddle = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1d2y2qh6xml4w6p15kaz1v2ryb8p3nm6yy5x5mfygdrxgpsc63rd";
- type = "gem";
- };
- version = "1.0.9";
- };
gpgme = {
dependencies = ["mini_portile2"];
groups = ["default"];
diff --git a/contrib/nix/ruby2.5-shell.nix b/contrib/nix/ruby2.5-shell.nix
index e98f1bd7..d80847b0 100644
--- a/contrib/nix/ruby2.5-shell.nix
+++ b/contrib/nix/ruby2.5-shell.nix
@@ -11,9 +11,6 @@ let
lockfile = ./ruby2.5-Gemfile.lock;
gemset = ./ruby2.5-gemset.nix;
gemConfig = pkgs.defaultGemConfig // {
- fiddle = attrs: {
- buildInputs = [ pkgs.libffi ];
- };
# Workaround: remove rake from nativeBuildInputs, otherwise it causes
# xapian-bindings to build against the default Ruby version
# instead of our chosen version.
diff --git a/contrib/nix/ruby2.6-Gemfile.lock b/contrib/nix/ruby2.6-Gemfile.lock
index cecf0d16..c98c8f9d 100644
--- a/contrib/nix/ruby2.6-Gemfile.lock
+++ b/contrib/nix/ruby2.6-Gemfile.lock
@@ -5,7 +5,6 @@ GEM
benchmark (0.4.0)
chronic (0.10.2)
coderay (1.1.3)
- fiddle (1.0.9)
gpgme (2.0.23)
mini_portile2 (~> 2.7)
highline (2.0.3)
@@ -65,7 +64,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby2.6-gemset.nix b/contrib/nix/ruby2.6-gemset.nix
index 3dd13cfa..a6adc858 100644
--- a/contrib/nix/ruby2.6-gemset.nix
+++ b/contrib/nix/ruby2.6-gemset.nix
@@ -39,16 +39,6 @@
};
version = "1.1.3";
};
- fiddle = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1d2y2qh6xml4w6p15kaz1v2ryb8p3nm6yy5x5mfygdrxgpsc63rd";
- type = "gem";
- };
- version = "1.0.9";
- };
gpgme = {
dependencies = ["mini_portile2"];
groups = ["default"];
diff --git a/contrib/nix/ruby2.6-shell.nix b/contrib/nix/ruby2.6-shell.nix
index c7423f6f..f656d3bc 100644
--- a/contrib/nix/ruby2.6-shell.nix
+++ b/contrib/nix/ruby2.6-shell.nix
@@ -11,9 +11,6 @@ let
lockfile = ./ruby2.6-Gemfile.lock;
gemset = ./ruby2.6-gemset.nix;
gemConfig = pkgs.defaultGemConfig // {
- fiddle = attrs: {
- buildInputs = [ pkgs.libffi ];
- };
# Workaround: remove rake from nativeBuildInputs, otherwise it causes
# xapian-bindings to build against the default Ruby version
# instead of our chosen version.
diff --git a/contrib/nix/ruby2.7-Gemfile.lock b/contrib/nix/ruby2.7-Gemfile.lock
index 1825f05b..f8e98b8b 100644
--- a/contrib/nix/ruby2.7-Gemfile.lock
+++ b/contrib/nix/ruby2.7-Gemfile.lock
@@ -5,7 +5,6 @@ GEM
benchmark (0.4.0)
chronic (0.10.2)
coderay (1.1.3)
- fiddle (1.0.9)
gpgme (2.0.24)
mini_portile2 (~> 2.7)
highline (3.0.1)
@@ -69,7 +68,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby2.7-gemset.nix b/contrib/nix/ruby2.7-gemset.nix
index fa2012a9..3f72cb2f 100644
--- a/contrib/nix/ruby2.7-gemset.nix
+++ b/contrib/nix/ruby2.7-gemset.nix
@@ -39,16 +39,6 @@
};
version = "1.1.3";
};
- fiddle = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1d2y2qh6xml4w6p15kaz1v2ryb8p3nm6yy5x5mfygdrxgpsc63rd";
- type = "gem";
- };
- version = "1.0.9";
- };
gpgme = {
dependencies = ["mini_portile2"];
groups = ["default"];
diff --git a/contrib/nix/ruby3.0-Gemfile.lock b/contrib/nix/ruby3.0-Gemfile.lock
index 711dd3bd..f8e98b8b 100644
--- a/contrib/nix/ruby3.0-Gemfile.lock
+++ b/contrib/nix/ruby3.0-Gemfile.lock
@@ -5,7 +5,6 @@ GEM
benchmark (0.4.0)
chronic (0.10.2)
coderay (1.1.3)
- fiddle (1.1.6)
gpgme (2.0.24)
mini_portile2 (~> 2.7)
highline (3.0.1)
@@ -69,7 +68,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby3.0-gemset.nix b/contrib/nix/ruby3.0-gemset.nix
index 9c4e48ce..3f72cb2f 100644
--- a/contrib/nix/ruby3.0-gemset.nix
+++ b/contrib/nix/ruby3.0-gemset.nix
@@ -39,16 +39,6 @@
};
version = "1.1.3";
};
- fiddle = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1as92bp6pgkab73kj3mh5d1idjr9wykczz7r9i1pkn82wq4xks3r";
- type = "gem";
- };
- version = "1.1.6";
- };
gpgme = {
dependencies = ["mini_portile2"];
groups = ["default"];
diff --git a/contrib/nix/ruby3.1-Gemfile.lock b/contrib/nix/ruby3.1-Gemfile.lock
index bcac3866..7a0bea61 100644
--- a/contrib/nix/ruby3.1-Gemfile.lock
+++ b/contrib/nix/ruby3.1-Gemfile.lock
@@ -5,7 +5,6 @@ GEM
benchmark (0.4.0)
chronic (0.10.2)
coderay (1.1.3)
- fiddle (1.1.6)
gpgme (2.0.24)
mini_portile2 (~> 2.7)
highline (3.1.2)
@@ -79,7 +78,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby3.1-gemset.nix b/contrib/nix/ruby3.1-gemset.nix
index a004cd61..abb19bc7 100644
--- a/contrib/nix/ruby3.1-gemset.nix
+++ b/contrib/nix/ruby3.1-gemset.nix
@@ -39,16 +39,6 @@
};
version = "1.1.3";
};
- fiddle = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1as92bp6pgkab73kj3mh5d1idjr9wykczz7r9i1pkn82wq4xks3r";
- type = "gem";
- };
- version = "1.1.6";
- };
gpgme = {
dependencies = ["mini_portile2"];
groups = ["default"];
diff --git a/contrib/nix/ruby3.2-Gemfile.lock b/contrib/nix/ruby3.2-Gemfile.lock
index bcac3866..7a0bea61 100644
--- a/contrib/nix/ruby3.2-Gemfile.lock
+++ b/contrib/nix/ruby3.2-Gemfile.lock
@@ -5,7 +5,6 @@ GEM
benchmark (0.4.0)
chronic (0.10.2)
coderay (1.1.3)
- fiddle (1.1.6)
gpgme (2.0.24)
mini_portile2 (~> 2.7)
highline (3.1.2)
@@ -79,7 +78,6 @@ DEPENDENCIES
benchmark
bundler (>= 1.3, < 3)
chronic
- fiddle
gpgme (>= 2.0.2)
highline
locale (~> 2.0)
diff --git a/contrib/nix/ruby3.2-gemset.nix b/contrib/nix/ruby3.2-gemset.nix
index a004cd61..abb19bc7 100644
--- a/contrib/nix/ruby3.2-gemset.nix
+++ b/contrib/nix/ruby3.2-gemset.nix
@@ -39,16 +39,6 @@
};
version = "1.1.3";
};
- fiddle = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1as92bp6pgkab73kj3mh5d1idjr9wykczz7r9i1pkn82wq4xks3r";
- type = "gem";
- };
- version = "1.1.6";
- };
gpgme = {
dependencies = ["mini_portile2"];
groups = ["default"];
diff --git a/lib/sup/util/locale_fiddler.rb b/lib/sup/util/locale_fiddler.rb
deleted file mode 100644
index 38d0e1ab..00000000
--- a/lib/sup/util/locale_fiddler.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-## the following magic enables wide characters when used with a ruby
-## ncurses.so that's been compiled against libncursesw. (note the w.) why
-## this works, i have no idea. much like pretty much every aspect of
-## dealing with curses. cargo cult programming at its best.
-require 'fiddle'
-require 'fiddle/import'
-
-module LocaleFiddler
- extend Fiddle::Importer
-
- SETLOCALE_LIB = case RbConfig::CONFIG['arch']
- when /darwin/; "libc.dylib"
- when /cygwin/; "cygwin1.dll"
- when /freebsd/; "libc.so.7"
- else; "libc.so.6"
- end
-
- dlload SETLOCALE_LIB
- extern "char *setlocale(int, char const *)"
-
- def setlocale(type, string)
- LocaleFiddler.setlocale(type, string)
- end
-end
diff --git a/sup.gemspec b/sup.gemspec
index 875b304e..c3d8b3d0 100644
--- a/sup.gemspec
+++ b/sup.gemspec
@@ -62,7 +62,6 @@ SUP: please note that our old mailing lists have been shut down,
s.add_runtime_dependency "unicode-display_width"
s.add_runtime_dependency "string-scrub" if /^2\.0\./ =~ RUBY_VERSION
s.add_runtime_dependency "benchmark"
- s.add_runtime_dependency "fiddle"
s.add_development_dependency "bundler", ">= 1.3", "< 3"
s.add_development_dependency "rake"
diff --git a/test/unit/test_locale_fiddler.rb b/test/unit/test_locale_fiddler.rb
deleted file mode 100644
index 33ec634e..00000000
--- a/test/unit/test_locale_fiddler.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'test_helper'
-require 'sup/util/locale_fiddler'
-
-class TestFiddle < Minitest::Test
- # TODO this is a silly test
- def test_fiddle_set_locale
- before = LocaleDummy.setlocale(6, nil).to_s
- after = LocaleDummy.setlocale(6, "").to_s
- assert(before != after, "Expected locale to be fiddled with")
- end
-end
-
-class LocaleDummy
- extend LocaleFiddler
-end
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [sup.git] 06/08: use libmagic to detect attachment MIME types
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
` (4 preceding siblings ...)
2026-11-28 6:13 ` [sup.git] 05/08: call setlocale() through ncurses bindings instead of fiddle Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
2026-11-28 6:13 ` [sup.git] 07/08: clean up directory traversal in Maildir#poll Dan Callaghan
2026-11-28 6:13 ` [sup.git] 08/08: bring back sup-recover-sources from the dead Dan Callaghan
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/07f797437938d23a35e7541eccf99c93c899d2f6.html
commit 07f797437938d23a35e7541eccf99c93c899d2f6
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Fri Nov 20 09:43:34 2026 +1100
use libmagic to detect attachment MIME types
Fixes #282.
---
Manifest.txt | 21 +++++++++++
contrib/nix/Gemfile | 2 +-
contrib/nix/Gemfile.lock | 9 ++---
contrib/nix/gemset.nix | 42 ++++++----------------
contrib/nix/ruby2.4-Gemfile.lock | 7 ++--
contrib/nix/ruby2.4-gemset.nix | 32 ++++++-----------
contrib/nix/ruby2.4-shell.nix | 4 +++
contrib/nix/ruby2.5-Gemfile.lock | 7 ++--
contrib/nix/ruby2.5-gemset.nix | 32 ++++++-----------
contrib/nix/ruby2.5-shell.nix | 4 +++
contrib/nix/ruby2.6-Gemfile.lock | 7 ++--
contrib/nix/ruby2.6-gemset.nix | 32 ++++++-----------
contrib/nix/ruby2.6-shell.nix | 4 +++
contrib/nix/ruby2.7-Gemfile.lock | 7 ++--
contrib/nix/ruby2.7-gemset.nix | 32 ++++++-----------
contrib/nix/ruby2.7-shell.nix | 6 ++++
contrib/nix/ruby3.0-Gemfile.lock | 7 ++--
contrib/nix/ruby3.0-gemset.nix | 32 ++++++-----------
contrib/nix/ruby3.0-shell.nix | 6 ++++
contrib/nix/ruby3.1-Gemfile.lock | 9 ++---
contrib/nix/ruby3.1-gemset.nix | 42 ++++++----------------
contrib/nix/ruby3.1-shell.nix | 6 ++++
contrib/nix/ruby3.2-Gemfile.lock | 9 ++---
contrib/nix/ruby3.2-gemset.nix | 42 ++++++----------------
contrib/nix/ruby3.2-shell.nix | 6 ++++
contrib/nix/ruby3.3-shell.nix | 6 ++++
contrib/nix/ruby3.4-shell.nix | 4 +++
contrib/nix/ruby4.0-shell.nix | 4 +++
lib/sup/util.rb | 21 ++++++-----
sup.gemspec | 2 +-
test/fixtures/attachments/Cargo.toml | 4 +++
test/fixtures/attachments/Dockerfile | 3 ++
test/fixtures/attachments/Hello.pm | 7 ++++
test/fixtures/attachments/Makefile | 2 ++
test/fixtures/attachments/board.dtb | Bin 0 -> 145 bytes
test/fixtures/attachments/board.dts | 6 ++++
test/fixtures/attachments/component.wasm | Bin 0 -> 8 bytes
test/fixtures/attachments/configure | 2 ++
test/fixtures/attachments/cp1251.txt | 1 +
test/fixtures/attachments/firmware.hex | 2 ++
test/fixtures/attachments/git-format.patch | 23 ++++++++++++
test/fixtures/attachments/go.mod | 3 ++
test/fixtures/attachments/hello | Bin 0 -> 132 bytes
test/fixtures/attachments/hello.c | 8 +++++
test/fixtures/attachments/hello.py | 2 ++
test/fixtures/attachments/koi8.txt | 1 +
test/fixtures/attachments/main.rs | 3 ++
test/fixtures/attachments/main.ts | 2 ++
test/fixtures/attachments/minimal.pdf | 14 ++++++++
test/fixtures/attachments/module.wasm | Bin 0 -> 13 bytes
test/fixtures/attachments/traditional.patch | 9 +++++
test/unit/test_edit_message_mode.rb | 12 +++----
test/unit/test_rmail_message.rb | 54 ++++++++++++++++++++++++++--
53 files changed, 346 insertions(+), 256 deletions(-)
diff --git a/Manifest.txt b/Manifest.txt
index 03b5678e..472b0372 100644
--- a/Manifest.txt
+++ b/Manifest.txt
@@ -139,6 +139,27 @@ lib/sup/version.rb
sup.gemspec
test/dummy_buffer.rb
test/dummy_source.rb
+test/fixtures/attachments/Cargo.toml
+test/fixtures/attachments/Dockerfile
+test/fixtures/attachments/Hello.pm
+test/fixtures/attachments/Makefile
+test/fixtures/attachments/board.dtb
+test/fixtures/attachments/board.dts
+test/fixtures/attachments/component.wasm
+test/fixtures/attachments/configure
+test/fixtures/attachments/cp1251.txt
+test/fixtures/attachments/firmware.hex
+test/fixtures/attachments/git-format.patch
+test/fixtures/attachments/go.mod
+test/fixtures/attachments/hello
+test/fixtures/attachments/hello.c
+test/fixtures/attachments/hello.py
+test/fixtures/attachments/koi8.txt
+test/fixtures/attachments/main.rs
+test/fixtures/attachments/main.ts
+test/fixtures/attachments/minimal.pdf
+test/fixtures/attachments/module.wasm
+test/fixtures/attachments/traditional.patch
test/fixtures/bad-content-transfer-encoding-1.eml
test/fixtures/binary-content-transfer-encoding-2.eml
test/fixtures/blank-header-fields.eml
diff --git a/contrib/nix/Gemfile b/contrib/nix/Gemfile
index 6afd5a2f..0ac67a73 100644
--- a/contrib/nix/Gemfile
+++ b/contrib/nix/Gemfile
@@ -6,7 +6,7 @@ gem "rmail", ">= 1.1.2", "< 2"
gem "highline"
gem "optimist"
gem "lockfile"
-gem "mime-types", "> 2.0"
+gem "ruby-magic"
gem "locale", "~> 2.0"
gem "chronic"
gem "unicode", "~> 0.4.4"
diff --git a/contrib/nix/Gemfile.lock b/contrib/nix/Gemfile.lock
index 10ad08a0..16ca0dbd 100644
--- a/contrib/nix/Gemfile.lock
+++ b/contrib/nix/Gemfile.lock
@@ -17,12 +17,7 @@ GEM
locale (2.1.5)
fiddle
lockfile (2.1.3)
- logger (1.7.0)
method_source (1.1.0)
- mime-types (3.7.0)
- logger
- mime-types-data (~> 3.2025, >= 3.2025.0507)
- mime-types-data (3.2026.0922)
mini_portile2 (2.8.9)
minitest (5.27.0)
ncursesw (1.4.15)
@@ -61,6 +56,8 @@ GEM
rubocop-packaging (0.6.0)
lint_roller (~> 1.1.0)
rubocop (>= 1.72.1, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.13.0)
unicode (0.4.4.5)
unicode-display_width (3.3.0)
@@ -90,7 +87,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -99,6 +95,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/gemset.nix b/contrib/nix/gemset.nix
index 1472295e..28f31b42 100644
--- a/contrib/nix/gemset.nix
+++ b/contrib/nix/gemset.nix
@@ -132,16 +132,6 @@
};
version = "2.1.3";
};
- logger = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "00q2zznygpbls8asz5knjvvj2brr3ghmqxgr83xnrdj4rk3xwvhr";
- type = "gem";
- };
- version = "1.7.0";
- };
method_source = {
groups = ["default"];
platforms = [];
@@ -152,27 +142,6 @@
};
version = "1.1.0";
};
- mime-types = {
- dependencies = ["logger" "mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "0mjyxl7c0xzyqdqa8r45hqg7jcw2prp3hkp39mdf223g4hfgdsyw";
- type = "gem";
- };
- version = "3.7.0";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1bjq9hppcmpawin2a6px1msc3mdxjvndj73rfklg771v1zr8r6zl";
- type = "gem";
- };
- version = "3.2026.0922";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -359,6 +328,17 @@
};
version = "0.6.0";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby2.4-Gemfile.lock b/contrib/nix/ruby2.4-Gemfile.lock
index 99130e4e..ff8bc2e4 100644
--- a/contrib/nix/ruby2.4-Gemfile.lock
+++ b/contrib/nix/ruby2.4-Gemfile.lock
@@ -11,9 +11,6 @@ GEM
locale (2.1.3)
lockfile (2.1.3)
method_source (1.0.0)
- mime-types (3.4.1)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2022.0105)
mini_portile2 (2.8.0)
minitest (5.15.0)
ncursesw (1.4.15)
@@ -43,6 +40,8 @@ GEM
parser (>= 2.7.1.5)
rubocop-packaging (0.5.1)
rubocop (>= 0.89, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.11.0)
unicode (0.4.4.5)
unicode-display_width (2.2.0)
@@ -66,7 +65,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -75,6 +73,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/ruby2.4-gemset.nix b/contrib/nix/ruby2.4-gemset.nix
index 0e550914..681136b8 100644
--- a/contrib/nix/ruby2.4-gemset.nix
+++ b/contrib/nix/ruby2.4-gemset.nix
@@ -90,27 +90,6 @@
};
version = "1.0.0";
};
- mime-types = {
- dependencies = ["mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "0ipw892jbksbxxcrlx9g5ljq60qx47pm24ywgfbyjskbcl78pkvb";
- type = "gem";
- };
- version = "3.4.1";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "003gd7mcay800k2q4pb2zn8lwwgci4bhi42v2jvlidm8ksx03i6q";
- type = "gem";
- };
- version = "3.2022.0105";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -276,6 +255,17 @@
};
version = "0.5.1";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby2.4-shell.nix b/contrib/nix/ruby2.4-shell.nix
index 3663b55a..526179ab 100644
--- a/contrib/nix/ruby2.4-shell.nix
+++ b/contrib/nix/ruby2.4-shell.nix
@@ -11,6 +11,10 @@ let
lockfile = ./ruby2.4-Gemfile.lock;
gemset = ./ruby2.4-gemset.nix;
gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
# Workaround: remove rake from nativeBuildInputs, otherwise it causes
# xapian-bindings to build against the default Ruby version
# instead of our chosen version.
diff --git a/contrib/nix/ruby2.5-Gemfile.lock b/contrib/nix/ruby2.5-Gemfile.lock
index 974b47d2..3cd32ffe 100644
--- a/contrib/nix/ruby2.5-Gemfile.lock
+++ b/contrib/nix/ruby2.5-Gemfile.lock
@@ -11,9 +11,6 @@ GEM
locale (2.1.3)
lockfile (2.1.3)
method_source (1.0.0)
- mime-types (3.4.1)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2022.0105)
mini_portile2 (2.8.0)
minitest (5.16.2)
ncursesw (1.4.15)
@@ -43,6 +40,8 @@ GEM
parser (>= 3.1.1.0)
rubocop-packaging (0.5.1)
rubocop (>= 0.89, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.11.0)
unicode (0.4.4.5)
unicode-display_width (2.2.0)
@@ -66,7 +65,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -75,6 +73,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/ruby2.5-gemset.nix b/contrib/nix/ruby2.5-gemset.nix
index 277912a3..eb56d5cf 100644
--- a/contrib/nix/ruby2.5-gemset.nix
+++ b/contrib/nix/ruby2.5-gemset.nix
@@ -90,27 +90,6 @@
};
version = "1.0.0";
};
- mime-types = {
- dependencies = ["mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "0ipw892jbksbxxcrlx9g5ljq60qx47pm24ywgfbyjskbcl78pkvb";
- type = "gem";
- };
- version = "3.4.1";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "003gd7mcay800k2q4pb2zn8lwwgci4bhi42v2jvlidm8ksx03i6q";
- type = "gem";
- };
- version = "3.2022.0105";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -276,6 +255,17 @@
};
version = "0.5.1";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby2.5-shell.nix b/contrib/nix/ruby2.5-shell.nix
index d80847b0..a45b6fa5 100644
--- a/contrib/nix/ruby2.5-shell.nix
+++ b/contrib/nix/ruby2.5-shell.nix
@@ -11,6 +11,10 @@ let
lockfile = ./ruby2.5-Gemfile.lock;
gemset = ./ruby2.5-gemset.nix;
gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
# Workaround: remove rake from nativeBuildInputs, otherwise it causes
# xapian-bindings to build against the default Ruby version
# instead of our chosen version.
diff --git a/contrib/nix/ruby2.6-Gemfile.lock b/contrib/nix/ruby2.6-Gemfile.lock
index c98c8f9d..51f5d3ee 100644
--- a/contrib/nix/ruby2.6-Gemfile.lock
+++ b/contrib/nix/ruby2.6-Gemfile.lock
@@ -12,9 +12,6 @@ GEM
locale (2.1.3)
lockfile (2.1.3)
method_source (1.0.0)
- mime-types (3.4.1)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2022.0105)
mini_portile2 (2.8.5)
minitest (5.16.2)
ncursesw (1.4.15)
@@ -45,6 +42,8 @@ GEM
parser (>= 3.1.1.0)
rubocop-packaging (0.5.1)
rubocop (>= 0.89, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.11.0)
unicode (0.4.4.5)
unicode-display_width (2.2.0)
@@ -68,7 +67,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -77,6 +75,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/ruby2.6-gemset.nix b/contrib/nix/ruby2.6-gemset.nix
index a6adc858..e9cbe7ac 100644
--- a/contrib/nix/ruby2.6-gemset.nix
+++ b/contrib/nix/ruby2.6-gemset.nix
@@ -100,27 +100,6 @@
};
version = "1.0.0";
};
- mime-types = {
- dependencies = ["mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "0ipw892jbksbxxcrlx9g5ljq60qx47pm24ywgfbyjskbcl78pkvb";
- type = "gem";
- };
- version = "3.4.1";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "003gd7mcay800k2q4pb2zn8lwwgci4bhi42v2jvlidm8ksx03i6q";
- type = "gem";
- };
- version = "3.2022.0105";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -286,6 +265,17 @@
};
version = "0.5.1";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby2.6-shell.nix b/contrib/nix/ruby2.6-shell.nix
index f656d3bc..e79b7f35 100644
--- a/contrib/nix/ruby2.6-shell.nix
+++ b/contrib/nix/ruby2.6-shell.nix
@@ -11,6 +11,10 @@ let
lockfile = ./ruby2.6-Gemfile.lock;
gemset = ./ruby2.6-gemset.nix;
gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
# Workaround: remove rake from nativeBuildInputs, otherwise it causes
# xapian-bindings to build against the default Ruby version
# instead of our chosen version.
diff --git a/contrib/nix/ruby2.7-Gemfile.lock b/contrib/nix/ruby2.7-Gemfile.lock
index f8e98b8b..26d77781 100644
--- a/contrib/nix/ruby2.7-Gemfile.lock
+++ b/contrib/nix/ruby2.7-Gemfile.lock
@@ -13,9 +13,6 @@ GEM
locale (2.1.4)
lockfile (2.1.3)
method_source (1.1.0)
- mime-types (3.5.2)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2024.0305)
mini_portile2 (2.8.6)
minitest (5.22.3)
ncursesw (1.4.15)
@@ -49,6 +46,8 @@ GEM
parser (>= 3.3.0.4)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.13.0)
unicode (0.4.4.5)
unicode-display_width (2.5.0)
@@ -72,7 +71,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -81,6 +79,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/ruby2.7-gemset.nix b/contrib/nix/ruby2.7-gemset.nix
index 3f72cb2f..98b5cc28 100644
--- a/contrib/nix/ruby2.7-gemset.nix
+++ b/contrib/nix/ruby2.7-gemset.nix
@@ -110,27 +110,6 @@
};
version = "1.1.0";
};
- mime-types = {
- dependencies = ["mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1r64z0m5zrn4k37wabfnv43wa6yivgdfk6cf2rpmmirlz889yaf1";
- type = "gem";
- };
- version = "3.5.2";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "00x7w5xqsj9m33v3vkmy23wipkkysafksib53ypzn27p5g81w455";
- type = "gem";
- };
- version = "3.2024.0305";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -306,6 +285,17 @@
};
version = "0.5.2";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby2.7-shell.nix b/contrib/nix/ruby2.7-shell.nix
index 17e59e60..e6edc744 100644
--- a/contrib/nix/ruby2.7-shell.nix
+++ b/contrib/nix/ruby2.7-shell.nix
@@ -10,5 +10,11 @@ let
gemfile = ./Gemfile;
lockfile = ./ruby2.7-Gemfile.lock;
gemset = ./ruby2.7-gemset.nix;
+ gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
+ };
};
in pkgs.mkShell { packages = [ gems gems.wrappedRuby pkgs.pandoc ]; }
diff --git a/contrib/nix/ruby3.0-Gemfile.lock b/contrib/nix/ruby3.0-Gemfile.lock
index f8e98b8b..26d77781 100644
--- a/contrib/nix/ruby3.0-Gemfile.lock
+++ b/contrib/nix/ruby3.0-Gemfile.lock
@@ -13,9 +13,6 @@ GEM
locale (2.1.4)
lockfile (2.1.3)
method_source (1.1.0)
- mime-types (3.5.2)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2024.0305)
mini_portile2 (2.8.6)
minitest (5.22.3)
ncursesw (1.4.15)
@@ -49,6 +46,8 @@ GEM
parser (>= 3.3.0.4)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.13.0)
unicode (0.4.4.5)
unicode-display_width (2.5.0)
@@ -72,7 +71,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -81,6 +79,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/ruby3.0-gemset.nix b/contrib/nix/ruby3.0-gemset.nix
index 3f72cb2f..98b5cc28 100644
--- a/contrib/nix/ruby3.0-gemset.nix
+++ b/contrib/nix/ruby3.0-gemset.nix
@@ -110,27 +110,6 @@
};
version = "1.1.0";
};
- mime-types = {
- dependencies = ["mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1r64z0m5zrn4k37wabfnv43wa6yivgdfk6cf2rpmmirlz889yaf1";
- type = "gem";
- };
- version = "3.5.2";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "00x7w5xqsj9m33v3vkmy23wipkkysafksib53ypzn27p5g81w455";
- type = "gem";
- };
- version = "3.2024.0305";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -306,6 +285,17 @@
};
version = "0.5.2";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby3.0-shell.nix b/contrib/nix/ruby3.0-shell.nix
index 9c373877..e34518be 100644
--- a/contrib/nix/ruby3.0-shell.nix
+++ b/contrib/nix/ruby3.0-shell.nix
@@ -10,5 +10,11 @@ let
gemfile = ./Gemfile;
lockfile = ./ruby3.0-Gemfile.lock;
gemset = ./ruby3.0-gemset.nix;
+ gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
+ };
};
in pkgs.mkShell { packages = [ gems gems.wrappedRuby pkgs.pandoc ]; }
diff --git a/contrib/nix/ruby3.1-Gemfile.lock b/contrib/nix/ruby3.1-Gemfile.lock
index 7a0bea61..4c09cad4 100644
--- a/contrib/nix/ruby3.1-Gemfile.lock
+++ b/contrib/nix/ruby3.1-Gemfile.lock
@@ -14,12 +14,7 @@ GEM
language_server-protocol (3.17.0.4)
locale (2.1.4)
lockfile (2.1.3)
- logger (1.7.0)
method_source (1.1.0)
- mime-types (3.6.2)
- logger
- mime-types-data (~> 3.2015)
- mime-types-data (3.2025.0402)
mini_portile2 (2.8.8)
minitest (5.25.5)
ncursesw (1.4.15)
@@ -55,6 +50,8 @@ GEM
parser (>= 3.3.0.4)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.13.0)
unicode (0.4.4.5)
unicode-display_width (2.5.0)
@@ -82,7 +79,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -91,6 +87,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/ruby3.1-gemset.nix b/contrib/nix/ruby3.1-gemset.nix
index abb19bc7..7b20f777 100644
--- a/contrib/nix/ruby3.1-gemset.nix
+++ b/contrib/nix/ruby3.1-gemset.nix
@@ -111,16 +111,6 @@
};
version = "2.1.3";
};
- logger = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "00q2zznygpbls8asz5knjvvj2brr3ghmqxgr83xnrdj4rk3xwvhr";
- type = "gem";
- };
- version = "1.7.0";
- };
method_source = {
groups = ["default"];
platforms = [];
@@ -131,27 +121,6 @@
};
version = "1.1.0";
};
- mime-types = {
- dependencies = ["logger" "mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1bv08jvx1g9ifjdyrp5hgalxkv7qxwfmfx0ba43ncrbfda7182b1";
- type = "gem";
- };
- version = "3.6.2";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1h0rhy0zf4ssrdr6cyliqijxga94cd64ij2gkw6jdx3bww1cap25";
- type = "gem";
- };
- version = "3.2025.0402";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -338,6 +307,17 @@
};
version = "0.5.2";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby3.1-shell.nix b/contrib/nix/ruby3.1-shell.nix
index ef8487d4..a86282bc 100644
--- a/contrib/nix/ruby3.1-shell.nix
+++ b/contrib/nix/ruby3.1-shell.nix
@@ -10,5 +10,11 @@ let
gemfile = ./Gemfile;
lockfile = ./ruby3.1-Gemfile.lock;
gemset = ./ruby3.1-gemset.nix;
+ gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
+ };
};
in pkgs.mkShell { packages = [ gems gems.wrappedRuby pkgs.pandoc ]; }
diff --git a/contrib/nix/ruby3.2-Gemfile.lock b/contrib/nix/ruby3.2-Gemfile.lock
index 7a0bea61..4c09cad4 100644
--- a/contrib/nix/ruby3.2-Gemfile.lock
+++ b/contrib/nix/ruby3.2-Gemfile.lock
@@ -14,12 +14,7 @@ GEM
language_server-protocol (3.17.0.4)
locale (2.1.4)
lockfile (2.1.3)
- logger (1.7.0)
method_source (1.1.0)
- mime-types (3.6.2)
- logger
- mime-types-data (~> 3.2015)
- mime-types-data (3.2025.0402)
mini_portile2 (2.8.8)
minitest (5.25.5)
ncursesw (1.4.15)
@@ -55,6 +50,8 @@ GEM
parser (>= 3.3.0.4)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
+ ruby-magic (0.6.0)
+ mini_portile2 (~> 2.8)
ruby-progressbar (1.13.0)
unicode (0.4.4.5)
unicode-display_width (2.5.0)
@@ -82,7 +79,6 @@ DEPENDENCIES
highline
locale (~> 2.0)
lockfile
- mime-types (> 2.0)
minitest (~> 5.5)
ncursesw (~> 1.4.0)
optimist
@@ -91,6 +87,7 @@ DEPENDENCIES
rmail (>= 1.1.2, < 2)
rr (~> 1.1)
rubocop-packaging
+ ruby-magic
unicode (~> 0.4.4)
unicode-display_width
xapian-ruby (~> 1.2)
diff --git a/contrib/nix/ruby3.2-gemset.nix b/contrib/nix/ruby3.2-gemset.nix
index abb19bc7..7b20f777 100644
--- a/contrib/nix/ruby3.2-gemset.nix
+++ b/contrib/nix/ruby3.2-gemset.nix
@@ -111,16 +111,6 @@
};
version = "2.1.3";
};
- logger = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "00q2zznygpbls8asz5knjvvj2brr3ghmqxgr83xnrdj4rk3xwvhr";
- type = "gem";
- };
- version = "1.7.0";
- };
method_source = {
groups = ["default"];
platforms = [];
@@ -131,27 +121,6 @@
};
version = "1.1.0";
};
- mime-types = {
- dependencies = ["logger" "mime-types-data"];
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1bv08jvx1g9ifjdyrp5hgalxkv7qxwfmfx0ba43ncrbfda7182b1";
- type = "gem";
- };
- version = "3.6.2";
- };
- mime-types-data = {
- groups = ["default"];
- platforms = [];
- source = {
- remotes = ["https://rubygems.org"];
- sha256 = "1h0rhy0zf4ssrdr6cyliqijxga94cd64ij2gkw6jdx3bww1cap25";
- type = "gem";
- };
- version = "3.2025.0402";
- };
mini_portile2 = {
groups = ["default"];
platforms = [];
@@ -338,6 +307,17 @@
};
version = "0.5.2";
};
+ ruby-magic = {
+ dependencies = ["mini_portile2"];
+ groups = ["default"];
+ platforms = [];
+ source = {
+ remotes = ["https://rubygems.org"];
+ sha256 = "00b15fd74bkrxfqbx1gg2nw78fs7lvmn8mf92bway8vxgf3kh8bv";
+ type = "gem";
+ };
+ version = "0.6.0";
+ };
ruby-progressbar = {
groups = ["default"];
platforms = [];
diff --git a/contrib/nix/ruby3.2-shell.nix b/contrib/nix/ruby3.2-shell.nix
index f15c31ef..7f0215be 100644
--- a/contrib/nix/ruby3.2-shell.nix
+++ b/contrib/nix/ruby3.2-shell.nix
@@ -10,5 +10,11 @@ let
gemfile = ./Gemfile;
lockfile = ./ruby3.2-Gemfile.lock;
gemset = ./ruby3.2-gemset.nix;
+ gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
+ };
};
in pkgs.mkShell { packages = [ gems gems.wrappedRuby pkgs.pandoc ]; }
diff --git a/contrib/nix/ruby3.3-shell.nix b/contrib/nix/ruby3.3-shell.nix
index 4064000e..d225948e 100644
--- a/contrib/nix/ruby3.3-shell.nix
+++ b/contrib/nix/ruby3.3-shell.nix
@@ -10,5 +10,11 @@ let
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
+ gemConfig = pkgs.defaultGemConfig // {
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
+ };
};
in pkgs.mkShell { packages = [ gems gems.wrappedRuby pkgs.pandoc ]; }
diff --git a/contrib/nix/ruby3.4-shell.nix b/contrib/nix/ruby3.4-shell.nix
index 39a842b1..8fc458b8 100644
--- a/contrib/nix/ruby3.4-shell.nix
+++ b/contrib/nix/ruby3.4-shell.nix
@@ -22,6 +22,10 @@ let
})
];
};
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
};
};
in pkgs.mkShell { packages = [ gems gems.wrappedRuby pkgs.pandoc ]; }
diff --git a/contrib/nix/ruby4.0-shell.nix b/contrib/nix/ruby4.0-shell.nix
index 37716a16..70dd1a9f 100644
--- a/contrib/nix/ruby4.0-shell.nix
+++ b/contrib/nix/ruby4.0-shell.nix
@@ -22,6 +22,10 @@ let
})
];
};
+ ruby-magic = attrs: {
+ buildInputs = [ pkgs.file ];
+ buildFlags = [ "--enable-system-libraries" ];
+ };
xapian-ruby =
attrs:
pkgs.defaultGemConfig.xapian-ruby attrs
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
index b4d58f9a..5096bd12 100644
--- a/lib/sup/util.rb
+++ b/lib/sup/util.rb
@@ -2,7 +2,7 @@
require 'thread'
require 'lockfile'
-require 'mime/types'
+require 'magic'
require 'pathname'
require 'rmail'
require 'set'
@@ -79,15 +79,21 @@ module RMail
class Message
def self.make_file_attachment fn
bfn = File.basename fn
- t = MIME::Types.type_for(bfn).first || MIME::Types.type_for("exe").first
+ content_type = File.mime(fn) || "application/octet-stream"
+ content_type = content_type.sub(/; charset=binary/, "") if content_type =~ /^application\//
payload = IO.binread fn
- ## Need to encode as base64 or quoted-printable if any lines are longer than 998 chars.
- encoding = if t.encoding != t.default_encoding and payload.each_line.any? { |l| l.length > 998 }
- t.default_encoding
+ encoding = if content_type =~ /^text\/|^message\/|^application\/mbox\b/i
+ if payload.include?("\0") || payload.each_line.any? { |l| l.bytesize > 998 } || payload =~ /\r(?!\n)/
+ "quoted-printable"
+ elsif !payload.ascii_only?
+ "8bit"
+ else
+ "7bit"
+ end
else
- t.encoding
+ "base64"
end
- make_attachment payload, t.content_type, encoding, bfn.to_s
+ make_attachment payload, content_type, encoding.dup, bfn.to_s
end
def charset
@@ -650,4 +656,3 @@ class FinishLine
@m.synchronize { !@over && @over = true }
end
end
-
diff --git a/sup.gemspec b/sup.gemspec
index c3d8b3d0..8d30490e 100644
--- a/sup.gemspec
+++ b/sup.gemspec
@@ -55,7 +55,7 @@ SUP: please note that our old mailing lists have been shut down,
s.add_runtime_dependency "highline"
s.add_runtime_dependency "optimist"
s.add_runtime_dependency "lockfile"
- s.add_runtime_dependency "mime-types", "> 2.0"
+ s.add_runtime_dependency "ruby-magic"
s.add_runtime_dependency "locale", "~> 2.0"
s.add_runtime_dependency "chronic"
s.add_runtime_dependency "unicode", "~> 0.4.4"
diff --git a/test/fixtures/attachments/Cargo.toml b/test/fixtures/attachments/Cargo.toml
new file mode 100644
index 00000000..60a39166
--- /dev/null
+++ b/test/fixtures/attachments/Cargo.toml
@@ -0,0 +1,4 @@
+[package]
+name = "hello"
+version = "0.1.0"
+edition = "2021"
diff --git a/test/fixtures/attachments/Dockerfile b/test/fixtures/attachments/Dockerfile
new file mode 100644
index 00000000..d4ff707c
--- /dev/null
+++ b/test/fixtures/attachments/Dockerfile
@@ -0,0 +1,3 @@
+FROM scratch
+COPY hello /
+CMD ["/hello"]
diff --git a/test/fixtures/attachments/Hello.pm b/test/fixtures/attachments/Hello.pm
new file mode 100644
index 00000000..ace1e670
--- /dev/null
+++ b/test/fixtures/attachments/Hello.pm
@@ -0,0 +1,7 @@
+package Hello;
+use strict;
+use warnings;
+
+sub greet { return "hello" }
+
+1;
diff --git a/test/fixtures/attachments/Makefile b/test/fixtures/attachments/Makefile
new file mode 100644
index 00000000..f554f032
--- /dev/null
+++ b/test/fixtures/attachments/Makefile
@@ -0,0 +1,2 @@
+hello: hello.c
+ $(CC) -o $@ $<
diff --git a/test/fixtures/attachments/board.dtb b/test/fixtures/attachments/board.dtb
new file mode 100644
index 00000000..a6fff46e
Binary files /dev/null and b/test/fixtures/attachments/board.dtb differ
diff --git a/test/fixtures/attachments/board.dts b/test/fixtures/attachments/board.dts
new file mode 100644
index 00000000..c8904203
--- /dev/null
+++ b/test/fixtures/attachments/board.dts
@@ -0,0 +1,6 @@
+/dts-v1/;
+
+/ {
+ model = "Example Board";
+ compatible = "example,board";
+};
diff --git a/test/fixtures/attachments/component.wasm b/test/fixtures/attachments/component.wasm
new file mode 100644
index 00000000..13d20e9f
Binary files /dev/null and b/test/fixtures/attachments/component.wasm differ
diff --git a/test/fixtures/attachments/configure b/test/fixtures/attachments/configure
new file mode 100755
index 00000000..9539c581
--- /dev/null
+++ b/test/fixtures/attachments/configure
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "checking for a C compiler... cc"
diff --git a/test/fixtures/attachments/cp1251.txt b/test/fixtures/attachments/cp1251.txt
new file mode 100644
index 00000000..2fbf7fb1
--- /dev/null
+++ b/test/fixtures/attachments/cp1251.txt
@@ -0,0 +1 @@
+� ���� ��������!
diff --git a/test/fixtures/attachments/firmware.hex b/test/fixtures/attachments/firmware.hex
new file mode 100644
index 00000000..ccea65f0
--- /dev/null
+++ b/test/fixtures/attachments/firmware.hex
@@ -0,0 +1,2 @@
+:04000000DEADBEEFC4
+:00000001FF
diff --git a/test/fixtures/attachments/git-format.patch b/test/fixtures/attachments/git-format.patch
new file mode 100644
index 00000000..42532efc
--- /dev/null
+++ b/test/fixtures/attachments/git-format.patch
@@ -0,0 +1,23 @@
+From 192aa8d87e24c94592647cbd804a64c3d4d01c07 Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <djc@djc.id.au>
+Date: Sun, 1 Nov 2026 20:26:40 +1100
+Subject: [PATCH] exit 42
+
+---
+ hello.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/hello.c b/hello.c
+index c8629c1..fd76ffb 100644
+--- a/hello.c
++++ b/hello.c
+@@ -1,5 +1,5 @@
+ int main(void)
+ {
+ printf("hello\n");
+- return 0;
++ return 42;
+ }
+--
+2.54.0
+
diff --git a/test/fixtures/attachments/go.mod b/test/fixtures/attachments/go.mod
new file mode 100644
index 00000000..476c039e
--- /dev/null
+++ b/test/fixtures/attachments/go.mod
@@ -0,0 +1,3 @@
+module example.com/hello
+
+go 1.21
diff --git a/test/fixtures/attachments/hello b/test/fixtures/attachments/hello
new file mode 100755
index 00000000..019a592d
Binary files /dev/null and b/test/fixtures/attachments/hello differ
diff --git a/test/fixtures/attachments/hello.c b/test/fixtures/attachments/hello.c
new file mode 100644
index 00000000..27441bf4
--- /dev/null
+++ b/test/fixtures/attachments/hello.c
@@ -0,0 +1,8 @@
+/* Copyright © 2026 Zoë Example */
+#include <stdio.h>
+
+int main(void)
+{
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/fixtures/attachments/hello.py b/test/fixtures/attachments/hello.py
new file mode 100644
index 00000000..8df28191
--- /dev/null
+++ b/test/fixtures/attachments/hello.py
@@ -0,0 +1,2 @@
+#!/usr/bin/env python3
+print("hello")
diff --git a/test/fixtures/attachments/koi8.txt b/test/fixtures/attachments/koi8.txt
new file mode 100644
index 00000000..ed8a41f0
--- /dev/null
+++ b/test/fixtures/attachments/koi8.txt
@@ -0,0 +1 @@
+������������!
diff --git a/test/fixtures/attachments/main.rs b/test/fixtures/attachments/main.rs
new file mode 100644
index 00000000..75275760
--- /dev/null
+++ b/test/fixtures/attachments/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("hello");
+}
diff --git a/test/fixtures/attachments/main.ts b/test/fixtures/attachments/main.ts
new file mode 100644
index 00000000..a2b6b306
--- /dev/null
+++ b/test/fixtures/attachments/main.ts
@@ -0,0 +1,2 @@
+const greeting: string = "hello";
+console.log(greeting);
diff --git a/test/fixtures/attachments/minimal.pdf b/test/fixtures/attachments/minimal.pdf
new file mode 100644
index 00000000..857888f0
--- /dev/null
+++ b/test/fixtures/attachments/minimal.pdf
@@ -0,0 +1,14 @@
+%PDF-1.0
+1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj
+2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj
+3 0 obj<</Type/Page/Parent 2 0 R/MediaBox[0 0 612 792]/Resources<<>>>>endobj
+xref
+0 4
+0000000000 65535 f
+0000000009 00000 n
+0000000052 00000 n
+0000000101 00000 n
+trailer<</Size 4/Root 1 0 R>>
+startxref
+178
+%%EOF
diff --git a/test/fixtures/attachments/module.wasm b/test/fixtures/attachments/module.wasm
new file mode 100644
index 00000000..00066296
Binary files /dev/null and b/test/fixtures/attachments/module.wasm differ
diff --git a/test/fixtures/attachments/traditional.patch b/test/fixtures/attachments/traditional.patch
new file mode 100644
index 00000000..d06790aa
--- /dev/null
+++ b/test/fixtures/attachments/traditional.patch
@@ -0,0 +1,9 @@
+diff -ur hello.orig/hello.c hello/hello.c
+--- hello.orig/hello.c 2026-11-01 21:02:17.097858746 +1100
++++ hello/hello.c 2026-11-01 21:02:20.600966920 +1100
+@@ -1,4 +1,4 @@
+ int main(void)
+ {
+- return 0;
++ return 42;
+ }
diff --git a/test/unit/test_edit_message_mode.rb b/test/unit/test_edit_message_mode.rb
index 5259fbe1..914252c8 100644
--- a/test/unit/test_edit_message_mode.rb
+++ b/test/unit/test_edit_message_mode.rb
@@ -122,10 +122,8 @@ class TestEditMessageMode < Minitest::Test
def test_attachment_8bit_non_utf8
body_content = "löl noñ-ÀSCII bodý"
## CP1251 is not UTF-8 compatible.
- ## This is a CSV only due to a quirk of mime-types, which wants to use 8bit for text/csv
- ## (whereas text/plain is quoted-printable).
attachment_content = "С днем рождения!\n".encode("cp1251")
- attachment_filename = File.join @path, "cp1251.csv"
+ attachment_filename = File.join @path, "cp1251.txt"
File.write attachment_filename, attachment_content
opts = {
@@ -134,7 +132,7 @@ class TestEditMessageMode < Minitest::Test
"To" => +"recip@example.invalid",
},
:attachments => {
- "cp1251.csv" => RMail::Message.make_file_attachment(attachment_filename),
+ "cp1251.txt" => RMail::Message.make_file_attachment(attachment_filename),
},
:body => [body_content],
}
@@ -148,13 +146,13 @@ class TestEditMessageMode < Minitest::Test
assert_equal "8bit", inline.header["Content-Transfer-Encoding"]
attachment = msg.part(1)
assert_equal attachment_content.b, attachment.body
- assert_equal 'text/csv; name="cp1251.csv"', attachment.header["Content-Type"]
- assert_equal 'attachment; filename="cp1251.csv"', attachment.header["Content-Disposition"]
+ assert_equal 'text/plain; charset=iso-8859-1; name="cp1251.txt"', attachment.header["Content-Type"]
+ assert_equal 'attachment; filename="cp1251.txt"', attachment.header["Content-Disposition"]
assert_equal "8bit", attachment.header["Content-Transfer-Encoding"]
## Also check the serialized message, which is what the send_message method uses.
assert msg.to_s.lines.include? body_content.b + "\n"
- assert msg.to_s.lines.include? "Content-Type: text/csv; name=\"cp1251.csv\"\n"
+ assert msg.to_s.lines.include? "Content-Type: text/plain; charset=iso-8859-1; name=\"cp1251.txt\"\n"
assert msg.to_s.lines.include? attachment_content.b
end
end
diff --git a/test/unit/test_rmail_message.rb b/test/unit/test_rmail_message.rb
index d0ef48f1..25a8d1d1 100644
--- a/test/unit/test_rmail_message.rb
+++ b/test/unit/test_rmail_message.rb
@@ -16,21 +16,69 @@ class TestRMailMessage < Minitest::Test
File.write filename, "<html></html>"
a = RMail::Message.make_file_attachment(filename)
- assert_equal "text/html; name=\"test.html\"", a.header["Content-Type"]
+ assert_equal "text/html; charset=us-ascii; name=\"test.html\"", a.header["Content-Type"]
assert_equal "attachment; filename=\"test.html\"", a.header["Content-Disposition"]
- assert_equal "8bit", a.header["Content-Transfer-Encoding"]
+ assert_equal "7bit", a.header["Content-Transfer-Encoding"]
end
def test_make_file_attachment_text_with_long_lines
+ skip "libmagic 5.40 misdetects this attachment as application/octet-stream" if Magic.version == 540
filename = File.join @path, "test.html"
File.write filename, "a" * 1023
a = RMail::Message.make_file_attachment(filename)
- assert_equal "text/html; name=\"test.html\"", a.header["Content-Type"]
+ assert_equal "text/plain; charset=us-ascii; name=\"test.html\"", a.header["Content-Type"]
assert_equal "attachment; filename=\"test.html\"", a.header["Content-Disposition"]
assert_equal "quoted-printable", a.header["Content-Transfer-Encoding"]
qp_encoded = ("a" * 73 + "=\n") * 14 + "a=\n"
assert_equal qp_encoded, a.body
end
+
+ def test_make_file_attachment_mimetype_guessing
+ [
+ ["git-format.patch", 'application/mbox; charset=us-ascii; name="git-format.patch"', "7bit"],
+ ["traditional.patch", 'text/x-diff; charset=us-ascii; name="traditional.patch"', "7bit"],
+ ["configure", 'text/x-shellscript; charset=us-ascii; name="configure"', "7bit"],
+ ["hello.c", 'text/x-c; charset=utf-8; name="hello.c"', "8bit"],
+ ["Makefile", 'text/plain; charset=us-ascii; name="Makefile"', "7bit"],
+ ["Dockerfile", 'text/plain; charset=us-ascii; name="Dockerfile"', "7bit"],
+ ["Cargo.toml", 'text/plain; charset=us-ascii; name="Cargo.toml"', "7bit"],
+ ["firmware.hex", 'text/x-hex; charset=us-ascii; name="firmware.hex"', "7bit"],
+ ["go.mod", 'text/plain; charset=us-ascii; name="go.mod"', "7bit"],
+ ["Hello.pm", 'text/plain; charset=us-ascii; name="Hello.pm"', "7bit"],
+ ["hello.py", 'text/x-script.python; charset=us-ascii; name="hello.py"', "7bit"],
+ ["main.rs", 'text/x-c; charset=us-ascii; name="main.rs"', "7bit"],
+ ["main.ts", 'text/plain; charset=us-ascii; name="main.ts"', "7bit"],
+ ["koi8.txt", 'text/plain; charset=iso-8859-1; name="koi8.txt"', "8bit"],
+ ["cp1251.txt", 'text/plain; charset=iso-8859-1; name="cp1251.txt"', "8bit"],
+ ["minimal.pdf", 'application/pdf; charset=us-ascii; name="minimal.pdf"', "base64"],
+ ["board.dtb", 'application/octet-stream; name="board.dtb"', "base64"],
+ ["hello", 'application/x-executable; name="hello"', "base64"],
+ ["module.wasm", 'application/wasm; name="module.wasm"', "base64"],
+ ["component.wasm", 'application/wasm; name="component.wasm"', "base64"],
+ ].each do |fn, expected_content_type, expected_encoding|
+ a = RMail::Message.make_file_attachment fixture_path("attachments/#{fn}")
+ expected_content_type.sub!(/text\/x-hex/, "text/plain") unless Magic.version >= 546
+ expected_content_type.sub!(/application\/mbox/, "text/x-diff") unless Magic.version >= 546
+ expected_content_type.sub!(/application\/wasm/, "application/octet-stream") unless Magic.version >= 543
+ expected_content_type.sub!(/application\/wasm/, "application/octet-stream") if fn == "module.wasm" and Magic.version >= 547
+ expected_content_type.sub!(/application\/wasm/, "application/octet-stream") if fn == "component.wasm" and Magic.version < 547
+ assert_equal expected_content_type, a.header["Content-Type"]
+ assert_equal expected_encoding, a.header["Content-Transfer-Encoding"]
+ assert_equal File.binread(fixture_path("attachments/#{fn}")), a.decode
+ end
+ end
+
+ def test_make_file_attachment_nested_emails
+ [
+ ["simple-message.eml", 'message/rfc822; charset=us-ascii; name="simple-message.eml"', "7bit"],
+ ["utf8-header.eml", 'message/rfc822; charset=utf-8; name="utf8-header.eml"', "8bit"],
+ ].each do |fn, expected_content_type, expected_encoding|
+ a = RMail::Message.make_file_attachment fixture_path(fn)
+ assert_equal expected_content_type, a.header["Content-Type"]
+ assert_equal expected_encoding, a.header["Content-Transfer-Encoding"]
+ assert_equal File.binread(fixture_path(fn)), a.decode
+ end
+ end
end
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [sup.git] 07/08: clean up directory traversal in Maildir#poll
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
` (5 preceding siblings ...)
2026-11-28 6:13 ` [sup.git] 06/08: use libmagic to detect attachment MIME types Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
2026-11-28 6:13 ` [sup.git] 08/08: bring back sup-recover-sources from the dead Dan Callaghan
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/f096837ab5e6e700092784117ada2b93bc6e5033.html
commit f096837ab5e6e700092784117ada2b93bc6e5033
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sun Nov 22 18:09:11 2026 +1100
clean up directory traversal in Maildir#poll
---
lib/sup/maildir.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index 488698f1..ac61f577 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -130,8 +130,8 @@ class Maildir < Source
old_ids = benchmark(:maildir_read_index) { Index.instance.enum_for(:each_source_info, self.id, "#{d}/").to_a }
new_ids = benchmark(:maildir_read_dir) {
Dir.open(subdir).select {
- |f| !File.directory? f}.map {
- |x| File.join(d,File.basename(x)) }.sort }
+ |f| !File.directory? File.join(subdir, f) }.map {
+ |f| File.join(d, f) }.sort }
added += new_ids - old_ids
deleted += old_ids - new_ids
debug "#{old_ids.size} in index, #{new_ids.size} in filesystem"
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [sup.git] 08/08: bring back sup-recover-sources from the dead
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
` (6 preceding siblings ...)
2026-11-28 6:13 ` [sup.git] 07/08: clean up directory traversal in Maildir#poll Dan Callaghan
@ 2026-11-28 6:13 ` Dan Callaghan
7 siblings, 0 replies; 9+ messages in thread
From: Dan Callaghan @ 2026-11-28 6:13 UTC (permalink / raw)
To: sup-commits
New commit on branch develop:
https://supmua.dev/git/sup/commit/53f07beb4310b71784861d4d81db6425b4af33c7.html
commit 53f07beb4310b71784861d4d81db6425b4af33c7
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sun Nov 22 18:03:06 2026 +1100
bring back sup-recover-sources from the dead
---
Manifest.txt | 1 +
bin/sup-recover-sources | 118 +++++++++++++--------------
lib/sup/index.rb | 9 +-
lib/sup/maildir.rb | 10 +++
lib/sup/mbox.rb | 16 ++++
lib/sup/source.rb | 6 ++
test/integration/test_sup-recover-sources.rb | 68 +++++++++++++++
7 files changed, 164 insertions(+), 64 deletions(-)
diff --git a/Manifest.txt b/Manifest.txt
index 472b0372..836470a6 100644
--- a/Manifest.txt
+++ b/Manifest.txt
@@ -198,6 +198,7 @@ test/integration/test_index.rb
test/integration/test_maildir.rb
test/integration/test_mbox.rb
test/integration/test_sup-add.rb
+test/integration/test_sup-recover-sources.rb
test/integration/test_sup-sync-back-maildir.rb
test/test_crypto.rb
test/test_header_parsing.rb
diff --git a/bin/sup-recover-sources b/bin/sup-recover-sources
index 2d62c32c..29ac76fa 100755
--- a/bin/sup-recover-sources
+++ b/bin/sup-recover-sources
@@ -2,20 +2,12 @@
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
-require 'optparse'
-
-$opts = {
- :unusual => false,
- :archive => false,
- :scan_num => 10,
-}
-
-
-OPTIONPARSERSUCKS = "\n" + " " * 38
-OptionParser.new do |opts|
- opts.banner = <<EOS
-Usage: sup-recover-sources [options] <source>+
+require 'optimist'
+require 'sup'
+opts = Optimist::options do
+ version "sup-recover-sources (sup #{Redwood::VERSION})"
+ banner <<EOS
Rebuilds a lost sources.yaml file by reading messages from a list of
sources and determining, for each source, the most prevalent
'source_id' field of messages from that source in the index.
@@ -24,64 +16,70 @@ The only non-deterministic component to this is that if the same
message appears in multiple sources, those sources may be
mis-diagnosed by this program.
+Usage:
+ sup-recover-sources [options] <source>*
+
+where <source>* is one or more source URIs.
+
If the first N messages (--scan-num below) all have the same source_id
in the index, the source will be added to sources.yaml. Otherwise, the
distribution will be printed, and you will have to add it by hand.
-The offset pointer into the sources will be set to the end of the source,
-so you will have to run sup-import --rebuild for each new source after
-doing this.
-
Options include:
EOS
+ opt :unusual, "Mark sources as 'unusual'. They will not be polled automatically.", :default => false, :short => :none
+ opt :archive, "Mark sources as 'archive'. New messages from these sources will not appear in the inbox.", :default => false, :short => :none
+ opt :scan_num, "Number of messages to scan per source.", :default => 10, :short => :none
+end
- opts.on("--unusual", "Mark sources as 'unusual'. Only usual#{OPTIONPARSERSUCKS}sources will be polled by hand. Default:#{OPTIONPARSERSUCKS}#{$opts[:unusual]}.") { $opts[:unusual] = true }
-
- opts.on("--archive", "Mark sources as 'archive'. New messages#{OPTIONPARSERSUCKS}from these sources will not appear in#{OPTIONPARSERSUCKS}the inbox. Default: #{$opts[:archive]}.") { $opts[:archive] = true }
-
- opts.on("--scan-num N", Integer, "Number of messages to scan per source.#{OPTIONPARSERSUCKS}Default: #{$opts[:scan_num]}.") do |n|
- $opts[:scan_num] = n
- end
-
- opts.on_tail("-h", "--help", "Show this message") do
- puts opts
- exit
- end
-end.parse(ARGV)
+Optimist::die "nothing to do: no sources given" if ARGV.empty?
-require "sup"
Redwood::start
-puts "loading index..."
index = Redwood::Index.init
index.load
-puts "loaded index of #{index.size} messages"
-
-ARGV.each do |fn|
- next if Redwood::SourceManager.source_for fn
- ## TODO: merge this code with the same snippet in import
- source = Redwood::MBox.new(fn, nil, !$opts[:unusual], $opts[:archive])
-
- source_ids = Hash.new 0
- count = 0
- source.each do |offset, labels|
- m = Redwood::Message.new :source => source, :source_info => offset
- m.load_from_source!
- source_id = Redwood::SourceManager.source_for_id m.id
- next unless source_id
- source_ids[source_id] += 1
- count += 1
- break if count == $opts[:scan_num]
- end
-
- if source_ids.size == 1
- id = source_ids.keys.first.to_i
- puts "assigned #{source} to #{source_ids.keys.first}"
- source.id = id
- Redwood::SourceManager.add_source source
- else
- puts ">> unable to determine #{source}: #{source_ids.inspect}"
+begin
+ ARGV.each do |uri|
+ next if Redwood::SourceManager.source_for uri
+
+ source =
+ case uri
+ when /^maildir:/
+ Redwood::Maildir.new uri, !opts[:unusual], opts[:archive], false, nil, []
+ when /^mbox:/
+ Redwood::MBox.new uri, !opts[:unusual], opts[:archive], nil, []
+ else
+ Optimist::die "Sources must be specified with a maildir:// or mbox:// URI"
+ end
+
+ source_ids = Hash.new 0
+ count = 0
+ source.each_message do |source_info|
+ location = Redwood::Location.new(source, source_info)
+ debug "checking message from #{source_info}"
+ m = Redwood::Message.new :locations => [location]
+ m.load_from_source!
+ indexed_source_ids = index.locations_for_id(m.id).select { |s, i| i == source_info }.map { |s, i| s }
+ if indexed_source_ids.empty?
+ debug "not found in index"
+ next
+ end
+ debug "found with source ids #{indexed_source_ids.inspect}"
+ indexed_source_ids.each { |id| source_ids[id] += 1 }
+ count += 1
+ break if count == opts[:scan_num]
+ end
+
+ if source_ids.size == 1
+ id = source_ids.keys.first.to_i
+ puts "assigned #{source} to #{source_ids.keys.first}"
+ source.id = id
+ Redwood::SourceManager.add_source source
+ else
+ puts ">> unable to determine #{source}: #{source_ids.inspect}"
+ end
end
+ensure
+ index.save
+ Redwood::finish
end
-
-index.save
diff --git a/lib/sup/index.rb b/lib/sup/index.rb
index f5ac72fe..27d8cbf5 100644
--- a/lib/sup/index.rb
+++ b/lib/sup/index.rb
@@ -327,10 +327,11 @@ EOS
def optimize
end
- ## Return the id source of the source the message with the given message-id
- ## was synced from
- def source_for_id id
- synchronize { get_entry(id)[:source_id] }
+ ## Return the locations the message with the given message-id
+ ## was synced from, as an array of [source_id, source_info] pairs.
+ def locations_for_id id
+ return [] unless (entry = synchronize { get_entry(id) })
+ entry[:locations]
end
## Yields each term in the index that starts with prefix
diff --git a/lib/sup/maildir.rb b/lib/sup/maildir.rb
index ac61f577..bdf1dc8e 100644
--- a/lib/sup/maildir.rb
+++ b/lib/sup/maildir.rb
@@ -180,6 +180,16 @@ class Maildir < Source
nil
end
+ def each_message
+ %w(cur new).each do |d|
+ subdir = File.join @dir, d
+ Dir.open(subdir).each do |f|
+ next if File.directory? File.join(subdir, f)
+ yield File.join(d, f)
+ end
+ end
+ end
+
def labels? id
maildir_labels id
end
diff --git a/lib/sup/mbox.rb b/lib/sup/mbox.rb
index 471b89a6..38d328d9 100644
--- a/lib/sup/mbox.rb
+++ b/lib/sup/mbox.rb
@@ -163,6 +163,22 @@ class MBox < Source
end
end
+ def each_message &b
+ offsets = []
+ @mutex.synchronize do
+ ensure_open
+ offset = 0
+ end_offset = File.size @f
+ @f.seek offset
+ while offset < end_offset
+ offsets << offset
+ nil while line = @f.gets and not MBox::is_break_line? line
+ offset = @f.tell
+ end
+ end
+ offsets.each(&b)
+ end
+
def next_offset offset
@mutex.synchronize do
ensure_open
diff --git a/lib/sup/source.rb b/lib/sup/source.rb
index 56d2e7d7..96e22113 100644
--- a/lib/sup/source.rb
+++ b/lib/sup/source.rb
@@ -98,6 +98,12 @@ class Source
unimplemented
end
+ ## Yields each message info in this source.
+ ## Slow path only for sup-recover-sources. The normal path is poll.
+ def each_message
+ unimplemented
+ end
+
def valid? info
true
end
diff --git a/test/integration/test_sup-recover-sources.rb b/test/integration/test_sup-recover-sources.rb
new file mode 100644
index 00000000..54fef719
--- /dev/null
+++ b/test/integration/test_sup-recover-sources.rb
@@ -0,0 +1,68 @@
+require "test_helper"
+require "sup"
+require "yaml"
+
+class TestSupRecoverSources < Minitest::Test
+ def setup
+ @path = Dir.mktmpdir
+
+ @maildir = File.join @path, "test_maildir"
+ Dir.mkdir @maildir
+ %w[cur new tmp].each do |subdir|
+ Dir.mkdir (File.join @maildir, subdir)
+ end
+ msg_path = File.join @maildir, "new", "123.hostname"
+ FileUtils.copy_file fixture_path("simple-message.eml"), msg_path
+
+ @mbox = File.join @path, "test_mbox"
+ File.open(@mbox, "wb") do |f|
+ f.puts "From test@test #{Time.now.asctime}"
+ f.puts File.read(fixture_path("simple-message.eml"))
+ end
+
+ _out, _err = capture_subprocess_io do
+ assert system({"SUP_BASE" => @path}, "bin/sup-add", "maildir://#{@maildir}")
+ assert system({"SUP_BASE" => @path}, "bin/sup-add", "mbox://#{@mbox}")
+ assert system({"SUP_BASE" => @path}, "bin/sup-sync")
+ end
+ end
+
+ def teardown
+ FileUtils.rm_r @path
+ end
+
+ def test_recover_sources
+ File.delete File.join(@path, "sources.yaml")
+ source_uris = ["maildir://#{@maildir}", "mbox://#{@mbox}"]
+ out, _err = capture_subprocess_io do
+ assert system({"SUP_BASE" => @path}, "bin/sup-recover-sources", *source_uris)
+ end
+ assert_equal "assigned #{source_uris[0]} to 1\n", out.lines[0]
+ assert_equal "assigned #{source_uris[1]} to 2\n", out.lines[1]
+
+ sources_fn = File.join @path, "sources.yaml"
+ sources_yaml =
+ if YAML.respond_to?(:unsafe_load_file) # Ruby 3.1+
+ YAML::unsafe_load_file sources_fn
+ else
+ YAML::load_file sources_fn
+ end
+ assert_equal 2, sources_yaml.length
+ assert_instance_of Redwood::Maildir, sources_yaml[0]
+ assert_equal source_uris[0], sources_yaml[0].uri
+ assert_equal 1, sources_yaml[0].id
+ assert_instance_of Redwood::MBox, sources_yaml[1]
+ assert_equal source_uris[1], sources_yaml[1].uri
+ assert_equal 2, sources_yaml[1].id
+ end
+
+ def test_noop
+ ## All sources are already defined in sources.yaml so there is nothing to recover.
+ ## It should do nothing.
+ source_uris = ["maildir://#{@maildir}", "mbox://#{@mbox}"]
+ out, _err = capture_subprocess_io do
+ assert system({"SUP_BASE" => @path}, "bin/sup-recover-sources", *source_uris)
+ end
+ assert out.empty?
+ end
+end
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-28 6:13 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 6:13 [sup.git] branch develop updated (ce27c933 -> 53f07beb) Dan Callaghan
2026-11-28 6:13 ` [sup.git] 01/08: delete dead report_broken_sources method Dan Callaghan
2026-11-28 6:13 ` [sup.git] 02/08: sup-sync-back-maildir: remove broken negative short options Dan Callaghan
2026-11-28 6:13 ` [sup.git] 03/08: show both raw and encoded sizes of attachments Dan Callaghan
2026-11-28 6:13 ` [sup.git] 04/08: shell escape bounce destination addresses Dan Callaghan
2026-11-28 6:13 ` [sup.git] 05/08: call setlocale() through ncurses bindings instead of fiddle Dan Callaghan
2026-11-28 6:13 ` [sup.git] 06/08: use libmagic to detect attachment MIME types Dan Callaghan
2026-11-28 6:13 ` [sup.git] 07/08: clean up directory traversal in Maildir#poll Dan Callaghan
2026-11-28 6:13 ` [sup.git] 08/08: bring back sup-recover-sources from the dead Dan Callaghan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox