sup 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/checks.yml +70 -0
  3. data/.rubocop.yml +5 -0
  4. data/CONTRIBUTORS +3 -2
  5. data/Gemfile +5 -1
  6. data/History.txt +20 -0
  7. data/Manifest.txt +149 -0
  8. data/README.md +9 -3
  9. data/Rakefile +40 -1
  10. data/bin/sup-add +4 -8
  11. data/ext/mkrf_conf_xapian.rb +10 -4
  12. data/lib/sup/colormap.rb +1 -1
  13. data/lib/sup/hook.rb +1 -1
  14. data/lib/sup/index.rb +2 -2
  15. data/lib/sup/keymap.rb +1 -1
  16. data/lib/sup/maildir.rb +4 -4
  17. data/lib/sup/mbox.rb +4 -4
  18. data/lib/sup/message.rb +6 -5
  19. data/lib/sup/message_chunks.rb +27 -19
  20. data/lib/sup/modes/completion_mode.rb +0 -1
  21. data/lib/sup/modes/file_browser_mode.rb +2 -2
  22. data/lib/sup/modes/label_list_mode.rb +1 -1
  23. data/lib/sup/modes/search_list_mode.rb +2 -2
  24. data/lib/sup/modes/thread_view_mode.rb +1 -2
  25. data/lib/sup/rfc2047.rb +21 -6
  26. data/lib/sup/source.rb +8 -2
  27. data/lib/sup/textfield.rb +0 -1
  28. data/lib/sup/thread.rb +0 -1
  29. data/lib/sup/util.rb +28 -48
  30. data/lib/sup/version.rb +1 -1
  31. data/lib/sup.rb +12 -8
  32. data/man/sup-add.1 +15 -15
  33. data/man/sup-config.1 +11 -11
  34. data/man/sup-dump.1 +9 -9
  35. data/man/sup-import-dump.1 +15 -15
  36. data/man/sup-psych-ify-config-files.1 +9 -9
  37. data/man/sup-recover-sources.1 +12 -12
  38. data/man/sup-sync-back-maildir.1 +14 -14
  39. data/man/sup-sync.1 +20 -20
  40. data/man/sup-tweak-labels.1 +16 -16
  41. data/man/sup.1 +21 -21
  42. data/sup.gemspec +6 -4
  43. data/test/dummy_source.rb +21 -15
  44. data/test/fixtures/embedded-message.eml +34 -0
  45. data/test/fixtures/non-ascii-header-in-nested-message.eml +36 -0
  46. data/test/fixtures/non-ascii-header.eml +8 -0
  47. data/test/fixtures/rfc2047-header-encoding.eml +15 -0
  48. data/test/fixtures/text-attachments-with-charset.eml +15 -1
  49. data/test/fixtures/utf8-header.eml +17 -0
  50. data/test/integration/test_mbox.rb +1 -1
  51. data/test/integration/test_sup-add.rb +83 -0
  52. data/test/test_crypto.rb +44 -0
  53. data/test/test_header_parsing.rb +9 -1
  54. data/test/test_helper.rb +7 -4
  55. data/test/test_message.rb +124 -32
  56. data/test/test_messages_dir.rb +13 -15
  57. data/test/unit/test_horizontal_selector.rb +4 -4
  58. data/test/unit/test_locale_fiddler.rb +1 -1
  59. data/test/unit/util/test_query.rb +1 -1
  60. data/test/unit/util/test_string.rb +3 -3
  61. data/test/unit/util/test_uri.rb +2 -2
  62. metadata +46 -18
  63. data/.travis.yml +0 -18
  64. data/bin/sup-psych-ify-config-files +0 -21
  65. data/test/integration/test_label_service.rb +0 -18
  66. data/test/test_yaml_migration.rb +0 -85
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 304755e3fd6b2e9aa86139810adb852249b93d7491471f17b2bd57e84b25489b
4
- data.tar.gz: 0c13ac3dd70310cae00eb59bcc2a90d13f8748e07fd3b38e74e9a7893cd18c1f
3
+ metadata.gz: 93d027a0f383edb73d1a2900ca991d8d8d8daca922f0088c18f5281ca04daeb4
4
+ data.tar.gz: 31b25e512227252a498baa651ea9b026ba452274dd5c67c99412dc2ef54f3e7a
5
5
  SHA512:
6
- metadata.gz: 62e6e7e76826426f53870b6fe8d8959777752360b6ff9aca1e5644e33e2e31b399b251007a4dc5a439f68419610a2a99b32a005117615d1d293c16283379150d
7
- data.tar.gz: 3cb2caa77a89ba1595365a93975e3caa006065a73787e075a2672e23670ecb3384c0f5c3a0e7bdb141fa31a3668e2870991097ece67de9d2d6b9a3fe1cbb2324
6
+ metadata.gz: 06211d3a91b76d20396afe9323bdf62d14acf61d13688333ae8f6409b55ff2120037df11e0a5e62e869e476868307a42216ee34e28f3621a05da0f9953a6cda3
7
+ data.tar.gz: f17bac030201cdabd4c6e3313a4178fb03f65f70992dcd4364cde425d1fd658408973b1758c7d45b13140dddde0e92f34006d6085140bbbb76164081083e9006
@@ -0,0 +1,70 @@
1
+ name: checks
2
+ on:
3
+ push:
4
+ branches:
5
+ - develop
6
+ pull_request:
7
+ branches:
8
+ - develop
9
+ permissions:
10
+ contents: read
11
+ jobs:
12
+ rake-ci:
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os:
17
+ - ubuntu-latest
18
+ - macos-latest
19
+ ruby-version:
20
+ - '2.0'
21
+ - '2.1'
22
+ # Ruby 2.2 fails installing sup gem with a nonsensical error:
23
+ # Could not find 'xapian-ruby' (~> 1.2) among 21 total gem(s)
24
+ #- '2.2'
25
+ - '2.3'
26
+ - '2.4'
27
+ - '2.5'
28
+ - '2.6'
29
+ - '2.7'
30
+ - '3.0'
31
+ - '3.1'
32
+ exclude:
33
+ # xapian-bindings 1.2.2 fails to build on MacOS:
34
+ # clang: warning: include path for libstdc++ headers not found; pass
35
+ # '-stdlib=libc++' on the command line to use the libc++ standard
36
+ # library instead [-Wstdlibcxx-not-found]
37
+ # xapian_wrap.cc:1836:10: fatal error: 'string' file not found
38
+ # Probably just wrong compiler command or some mess that I can't be
39
+ # bothered to figure out.
40
+ - os: macos-latest
41
+ ruby-version: '2.0'
42
+ # xapian-bindings 1.4.18 fails to build with Ruby 3.0+ on MacOS:
43
+ # error: '__declspec' attributes are not enabled; use '-fdeclspec' or
44
+ # '-fms-extensions' to enable support for __declspec attributes
45
+ # Needs this fix:
46
+ # https://github.com/xapian/xapian/commit/63a06768a250b0bb4821b835f011e8214d560f8e
47
+ - os: macos-latest
48
+ ruby-version: '3.0'
49
+ - os: macos-latest
50
+ ruby-version: '3.1'
51
+ runs-on: ${{ matrix.os }}
52
+ steps:
53
+ - name: Install pandoc
54
+ run: sudo apt-get install -y pandoc
55
+ if: runner.os == 'Linux'
56
+ - name: Install pandoc
57
+ run: brew install pandoc
58
+ if: runner.os == 'macOS'
59
+ - uses: actions/checkout@v3
60
+ with:
61
+ submodules: recursive
62
+ - name: Set up Ruby
63
+ uses: ruby/setup-ruby@v1
64
+ with:
65
+ ruby-version: ${{ matrix.ruby-version }}
66
+ bundler-cache: true
67
+ - name: Run Rake ci task
68
+ run: bundle exec rake ci
69
+ - name: Test gem installation
70
+ run: gem install pkg/sup-*.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ require:
2
+ - rubocop-packaging
3
+
4
+ AllCops:
5
+ DisabledByDefault: true
data/CONTRIBUTORS CHANGED
@@ -2,22 +2,22 @@ William Morgan <william at the twitter dot coms>
2
2
  Rich Lane <rlane at the club.cc.cmu dot edus>
3
3
  Gaute Hope <eg at the gaute.vetsj dot coms>
4
4
  Whyme Lyu <callme5long at the gmail dot coms>
5
+ Dan Callaghan <djc at the djc.id dot aus>
5
6
  Hamish Downer <dmishd at the gmail dot coms>
6
7
  Zeger-Jan van de Weg <mail at the zjvandeweg dot nls>
7
8
  Damien Leone <damien.leone at the fensalir dot frs>
8
9
  Sascha Silbe <sascha-pgp at the silbe dot orgs>
10
+ Iain Parris <ipv2.vcs at the parris dot orgs>
9
11
  Eric Weikl <eric.weikl at the gmx dot nets>
10
12
  Paweł Wilk <siefca at the gnu dot orgs>
11
13
  Matthieu Rakotojaona <matthieu.rakotojaona at the gmail dot coms>
12
14
  Ismo Puustinen <ismo at the iki dot fis>
13
- Dan Callaghan <djc at the djc.id dot aus>
14
15
  Nicolas Pouillard <nicolas.pouillard at the gmail dot coms>
15
16
  Michael Stapelberg <michael at the stapelberg dot des>
16
17
  Eric Sherman <hyperbolist at the gmail dot coms>
17
18
  Tero Tilus <tero at the tilus dot nets>
18
19
  Ben Walton <bwalton at the artsci.utoronto dot cas>
19
20
  Scott Bonds <scott at the ggr dot coms>
20
- Iain Parris <ipv2.vcs at the parris dot orgs>
21
21
  Mike Stipicevic <stipim at the rpi dot edus>
22
22
  Martin Bähr <mbaehr at the societyserver dot orgs>
23
23
  Timon Vonk <timonv at the gmail dot coms>
@@ -87,6 +87,7 @@ Todd Eisenberger <teisenbe at the andrew.cmu dot edus>
87
87
  Johannes Larsen <mail at the johslarsen dot nets>
88
88
  Steven Schmeiser <steven at the schmeiser dot orgs>
89
89
  Steven Walter <swalter at the monarch.(none)>
90
+ Utkarsh Gupta <utkarsh at the debian dot orgs>
90
91
  Michael Dwyer <mdwyer at the michaelmdwyer dot coms>
91
92
  Kyle Hunt <Kyle_Hunt at the ymail dot coms>
92
93
  William A. Kennington III <william at the wkennington dot coms>
data/Gemfile CHANGED
@@ -2,7 +2,11 @@ source 'https://rubygems.org/'
2
2
 
3
3
  if !RbConfig::CONFIG['arch'].include?('openbsd')
4
4
  # update version in ext/mkrf_conf_xapian.rb as well.
5
- gem 'xapian-ruby', '~> 1.2'
5
+ if /^2\.0\./ =~ RUBY_VERSION
6
+ gem 'xapian-ruby', ['~> 1.2', '< 1.3.6']
7
+ else
8
+ gem 'xapian-ruby', '~> 1.2'
9
+ end
6
10
  end
7
11
 
8
12
  gemspec
data/History.txt CHANGED
@@ -1,3 +1,23 @@
1
+ == 1.1 / 2022-05-23
2
+
3
+ * #588, #577: Sup is now compatible with and tested on Ruby 3.0 and Ruby 3.1.
4
+ * When the Sup gem installs xapian-ruby, it will install to the user gem
5
+ directory if the system gem directory is not writable. (Iain Parris)
6
+ * #571: To and From addresses of enclosed messages are now displayed normally,
7
+ instead of as Redwood::Person objects. (Iain Parris)
8
+ * #570: Fixed wording when displaying enclosed messages without Date header.
9
+ (Iain Parris)
10
+ * #205, #602: UTF-8 header values are now accepted and handled correctly, as
11
+ per RFC6532.
12
+ * #585: Text/plain attachments with invalid charset are now displayed as
13
+ US-ASCII (with high bytes replaced) instead of crashing.
14
+ * #424: Spaces are now accepted in RFC2047-encoded header words, even though
15
+ the RFC forbids them. (Dan Callaghan)
16
+ * Invalid RFC2047-encoded header words are now displayed in their raw form,
17
+ rather than trying to forcibly transcode them to UTF-8, as per the RFC's
18
+ recommendation. (Dan Callaghan)
19
+ * Sup now decodes UTF-7 correctly instead of crashing.
20
+
1
21
  == 1.0 / 2020-07-12
2
22
 
3
23
  No changes. The version number is incremented to 1.0 to reflect the fact that
data/Manifest.txt ADDED
@@ -0,0 +1,149 @@
1
+ .github/workflows/checks.yml
2
+ .gitignore
3
+ .gitmodules
4
+ .rubocop.yml
5
+ CONTRIBUTORS
6
+ Gemfile
7
+ HACKING
8
+ History.txt
9
+ LICENSE
10
+ Manifest.txt
11
+ README.md
12
+ Rakefile
13
+ ReleaseNotes
14
+ bin/sup
15
+ bin/sup-add
16
+ bin/sup-config
17
+ bin/sup-dump
18
+ bin/sup-import-dump
19
+ bin/sup-recover-sources
20
+ bin/sup-sync
21
+ bin/sup-sync-back-maildir
22
+ bin/sup-tweak-labels
23
+ contrib/colorpicker.rb
24
+ contrib/completion/_sup.bash
25
+ contrib/completion/_sup.zsh
26
+ devel/console.sh
27
+ devel/count-loc.sh
28
+ devel/load-index.rb
29
+ devel/profile.rb
30
+ devel/start-console.rb
31
+ doc/FAQ.txt
32
+ doc/Hooks.txt
33
+ doc/Philosophy.txt
34
+ doc/wiki
35
+ ext/mkrf_conf_xapian.rb
36
+ lib/sup.rb
37
+ lib/sup/account.rb
38
+ lib/sup/buffer.rb
39
+ lib/sup/colormap.rb
40
+ lib/sup/contact.rb
41
+ lib/sup/crypto.rb
42
+ lib/sup/draft.rb
43
+ lib/sup/hook.rb
44
+ lib/sup/horizontal_selector.rb
45
+ lib/sup/idle.rb
46
+ lib/sup/index.rb
47
+ lib/sup/interactive_lock.rb
48
+ lib/sup/keymap.rb
49
+ lib/sup/label.rb
50
+ lib/sup/logger.rb
51
+ lib/sup/logger/singleton.rb
52
+ lib/sup/maildir.rb
53
+ lib/sup/mbox.rb
54
+ lib/sup/message.rb
55
+ lib/sup/message_chunks.rb
56
+ lib/sup/mode.rb
57
+ lib/sup/modes/buffer_list_mode.rb
58
+ lib/sup/modes/completion_mode.rb
59
+ lib/sup/modes/compose_mode.rb
60
+ lib/sup/modes/console_mode.rb
61
+ lib/sup/modes/contact_list_mode.rb
62
+ lib/sup/modes/edit_message_async_mode.rb
63
+ lib/sup/modes/edit_message_mode.rb
64
+ lib/sup/modes/file_browser_mode.rb
65
+ lib/sup/modes/forward_mode.rb
66
+ lib/sup/modes/help_mode.rb
67
+ lib/sup/modes/inbox_mode.rb
68
+ lib/sup/modes/label_list_mode.rb
69
+ lib/sup/modes/label_search_results_mode.rb
70
+ lib/sup/modes/line_cursor_mode.rb
71
+ lib/sup/modes/log_mode.rb
72
+ lib/sup/modes/person_search_results_mode.rb
73
+ lib/sup/modes/poll_mode.rb
74
+ lib/sup/modes/reply_mode.rb
75
+ lib/sup/modes/resume_mode.rb
76
+ lib/sup/modes/scroll_mode.rb
77
+ lib/sup/modes/search_list_mode.rb
78
+ lib/sup/modes/search_results_mode.rb
79
+ lib/sup/modes/text_mode.rb
80
+ lib/sup/modes/thread_index_mode.rb
81
+ lib/sup/modes/thread_view_mode.rb
82
+ lib/sup/person.rb
83
+ lib/sup/poll.rb
84
+ lib/sup/rfc2047.rb
85
+ lib/sup/search.rb
86
+ lib/sup/sent.rb
87
+ lib/sup/service/label_service.rb
88
+ lib/sup/source.rb
89
+ lib/sup/tagger.rb
90
+ lib/sup/textfield.rb
91
+ lib/sup/thread.rb
92
+ lib/sup/time.rb
93
+ lib/sup/undo.rb
94
+ lib/sup/update.rb
95
+ lib/sup/util.rb
96
+ lib/sup/util/axe.rb
97
+ lib/sup/util/locale_fiddler.rb
98
+ lib/sup/util/ncurses.rb
99
+ lib/sup/util/path.rb
100
+ lib/sup/util/query.rb
101
+ lib/sup/util/uri.rb
102
+ lib/sup/version.rb
103
+ sup.gemspec
104
+ test/dummy_source.rb
105
+ test/fixtures/bad-content-transfer-encoding-1.eml
106
+ test/fixtures/binary-content-transfer-encoding-2.eml
107
+ test/fixtures/blank-header-fields.eml
108
+ test/fixtures/contacts.txt
109
+ test/fixtures/embedded-message.eml
110
+ test/fixtures/mailing-list-header.eml
111
+ test/fixtures/malicious-attachment-names.eml
112
+ test/fixtures/missing-from-to.eml
113
+ test/fixtures/missing-line.eml
114
+ test/fixtures/multi-part-2.eml
115
+ test/fixtures/multi-part.eml
116
+ test/fixtures/no-body.eml
117
+ test/fixtures/non-ascii-header-in-nested-message.eml
118
+ test/fixtures/non-ascii-header.eml
119
+ test/fixtures/rfc2047-header-encoding.eml
120
+ test/fixtures/simple-message.eml
121
+ test/fixtures/text-attachments-with-charset.eml
122
+ test/fixtures/utf8-header.eml
123
+ test/fixtures/zimbra-quote-with-bottom-post.eml
124
+ test/gnupg_test_home/.gpg-v21-migrated
125
+ test/gnupg_test_home/gpg.conf
126
+ test/gnupg_test_home/private-keys-v1.d/306D2EE90FF0014B5B9FD07E265C751791674140.key
127
+ test/gnupg_test_home/pubring.gpg
128
+ test/gnupg_test_home/receiver_pubring.gpg
129
+ test/gnupg_test_home/receiver_secring.gpg
130
+ test/gnupg_test_home/regen_keys.sh
131
+ test/gnupg_test_home/secring.gpg
132
+ test/gnupg_test_home/sup-test-2@foo.bar.asc
133
+ test/integration/test_maildir.rb
134
+ test/integration/test_mbox.rb
135
+ test/integration/test_sup-add.rb
136
+ test/test_crypto.rb
137
+ test/test_header_parsing.rb
138
+ test/test_helper.rb
139
+ test/test_message.rb
140
+ test/test_messages_dir.rb
141
+ test/test_yaml_regressions.rb
142
+ test/unit/service/test_label_service.rb
143
+ test/unit/test_contact.rb
144
+ test/unit/test_horizontal_selector.rb
145
+ test/unit/test_locale_fiddler.rb
146
+ test/unit/test_person.rb
147
+ test/unit/util/test_query.rb
148
+ test/unit/util/test_string.rb
149
+ test/unit/util/test_uri.rb
data/README.md CHANGED
@@ -57,9 +57,15 @@ some alternatives to consider:
57
57
  * [Notmuch](https://notmuchmail.org/) was inspired by Sup. There are a wide
58
58
  variety of [Notmuch clients](https://notmuchmail.org/frontends/) available.
59
59
  The most similar to Sup's look-and-feel is
60
- [Alot](https://github.com/pazz/alot) &mdash; also a curses-based frontend.
61
- Alot even ships with a built-in
62
- [Sup theme](https://github.com/pazz/alot/blob/master/extra/themes/sup)!
60
+ [Alot](https://github.com/pazz/alot) &mdash; also a curses-based front end.
61
+ Alot even ships with a
62
+ [built-in](https://github.com/pazz/alot/blob/master/extra/themes/sup)
63
+ [Sup theme](https://github.com/pazz/alot/wiki/Gallery#user-content-theme-sup)!
64
+
65
+ * [mu](https://www.djcbsoftware.nl/code/mu/) /
66
+ [mu4e](https://www.djcbsoftware.nl/code/mu/mu4e.html). Like Sup, a search-based
67
+ email back end, and also implemented using Xapian. The emacs-based front end
68
+ [is quite different](https://www.djcbsoftware.nl/code/mu/mu4e/Other-mail-clients.html).
63
69
 
64
70
  ## License
65
71
 
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'rake/testtask'
2
2
  require "bundler/gem_tasks"
3
3
 
4
+ # Manifest.txt file in same folder as this Rakefile
5
+ manifest_filename = "#{File.dirname(__FILE__)}/Manifest.txt"
6
+ git_ls_files_command = "git ls-files | LC_ALL=C sort"
7
+
4
8
  Rake::TestTask.new(:test) do |test|
5
9
  test.libs << 'test'
6
10
  test.test_files = FileList.new('test/**/test_*.rb')
@@ -9,7 +13,7 @@ end
9
13
  task :default => :test
10
14
 
11
15
  task :build => [:man]
12
- task :travis => [:test, :build]
16
+ task :ci => [:test, :rubocop_packaging, :check_manifest, :build]
13
17
 
14
18
  def test_pandoc
15
19
  return system("pandoc -v > /dev/null 2>&1")
@@ -50,3 +54,38 @@ task :clean do
50
54
  FileUtils.rm_r d if Dir.exist? d
51
55
  end
52
56
  end
57
+
58
+ task :manifest do
59
+ manifest = `#{git_ls_files_command}`
60
+ if $?.success? then
61
+ puts "Writing `git ls-files` output to #{manifest_filename}"
62
+ File.write(manifest_filename, manifest, mode: 'w')
63
+ else
64
+ abort "Failed to generate Manifest.txt (with `git ls-files`)"
65
+ end
66
+ end
67
+
68
+ task :check_manifest do
69
+ manifest = `#{git_ls_files_command}`
70
+ manifest_file_contents = File.read(manifest_filename)
71
+ if manifest == manifest_file_contents
72
+ puts "Manifest.txt OK"
73
+ else
74
+ puts "Manifest from `git ls-files`:\n#{manifest}"
75
+ STDERR.puts "Manifest.txt outdated. Please commit an updated Manifest.txt"
76
+ STDERR.puts "To generate Manifest.txt, run: rake manifest"
77
+ abort "Manifest.txt does not match `git ls-files`"
78
+ end
79
+ end
80
+
81
+ task :rubocop_packaging do
82
+ if /^2\.[012]\./ =~ RUBY_VERSION
83
+ puts "skipping rubocop-packaging checks on unsupported Ruby #{RUBY_VERSION}"
84
+ next
85
+ end
86
+ if system("rubocop --only Packaging")
87
+ puts "rubocop-packaging checks OK"
88
+ else
89
+ abort "rubocop-packaging checks failed"
90
+ end
91
+ end
data/bin/sup-add CHANGED
@@ -94,18 +94,14 @@ begin
94
94
  next
95
95
  end
96
96
 
97
- parsed_uri = URI(URI.escape(uri))
98
-
99
97
  source =
100
- case parsed_uri.scheme
101
- when "maildir"
98
+ case uri
99
+ when /^maildir:/
102
100
  Redwood::Maildir.new uri, !$opts[:unusual], $opts[:archive], $opts[:sync_back], nil, labels
103
- when "mbox"
101
+ when /^mbox:/
104
102
  Redwood::MBox.new uri, !$opts[:unusual], $opts[:archive], nil, labels
105
103
  when nil
106
- Optimist::die "Sources must be specified with an URI"
107
- else
108
- Optimist::die "Unknown source type #{parsed_uri.scheme.inspect}"
104
+ Optimist::die "Sources must be specified with a maildir:// or mbox:// URI"
109
105
  end
110
106
  @cli.say "Adding #{source}..."
111
107
  Redwood::SourceManager.add_source source
@@ -10,13 +10,19 @@ end
10
10
 
11
11
  puts "xapian: platform specific dependencies.."
12
12
 
13
- inst = Gem::DependencyInstaller.new
13
+ destination = File.writable?(Gem.dir) ? Gem.dir : Gem.user_dir
14
+ inst = Gem::DependencyInstaller.new(:install_dir => destination)
14
15
  begin
15
16
 
16
17
  if !RbConfig::CONFIG['arch'].include?('openbsd')
17
18
  # update version in Gemfile as well
18
19
  name = "xapian-ruby"
19
- version = "~> 1.2"
20
+ version =
21
+ if /^2\.0\./ =~ RUBY_VERSION
22
+ ["~> 1.2", "< 1.3.6"]
23
+ else
24
+ "~> 1.2"
25
+ end
20
26
 
21
27
  begin
22
28
  # try to load gem
@@ -34,8 +40,8 @@ begin
34
40
  STDERR.puts "xapian: openbsd: you have to install xapian-core and xapian-bindings manually, have a look at: https://github.com/sup-heliotrope/sup/wiki/Installation%3A-OpenBSD"
35
41
  end
36
42
 
37
- rescue
38
-
43
+ rescue StandardError => e
44
+ STDERR.puts "Unable to install #{name} gem: #{e.inspect}"
39
45
  exit(1)
40
46
 
41
47
  end
data/lib/sup/colormap.rb CHANGED
@@ -236,7 +236,7 @@ class Colormap
236
236
  @@instance.send meth, *a
237
237
  end
238
238
  # Performance shortcut
239
- def self.color_for *a; @@instance.color_for *a; end
239
+ def self.color_for(*a); @@instance.color_for(*a); end
240
240
  end
241
241
 
242
242
  end
data/lib/sup/hook.rb CHANGED
@@ -138,7 +138,7 @@ private
138
138
  returning IO.read(fn_for(name)) do
139
139
  debug "read '#{name}' from #{fn_for(name)}"
140
140
  end
141
- rescue SystemCallError => e
141
+ rescue SystemCallError
142
142
  #debug "disabled hook for '#{name}': #{e.message}"
143
143
  nil
144
144
  end
data/lib/sup/index.rb CHANGED
@@ -425,7 +425,7 @@ EOS
425
425
 
426
426
  ## gmail style "is" operator
427
427
  subs = subs.gsub(/\b(is|has):(\S+)\b/) do
428
- field, label = $1, $2
428
+ _field, label = $1, $2
429
429
  case label
430
430
  when "read"
431
431
  "-label:unread"
@@ -649,7 +649,7 @@ EOS
649
649
  end
650
650
 
651
651
  def synchronize &b
652
- @index_mutex.synchronize &b
652
+ @index_mutex.synchronize(&b)
653
653
  end
654
654
 
655
655
  def run_query xapian_query, offset, limit, checkatleast=0
data/lib/sup/keymap.rb CHANGED
@@ -98,7 +98,7 @@ EOS
98
98
  end
99
99
 
100
100
  def action_for kc
101
- action, help, keys = @map[kc.code]
101
+ action, help, _keys = @map[kc.code]
102
102
  [action, help]
103
103
  end
104
104
 
data/lib/sup/maildir.rb CHANGED
@@ -12,13 +12,13 @@ class Maildir < Source
12
12
  def initialize uri, usual=true, archived=false, sync_back=true, id=nil, labels=[]
13
13
  super uri, usual, archived, id
14
14
  @expanded_uri = Source.expand_filesystem_uri(uri)
15
- parts = @expanded_uri.match /^([a-zA-Z0-9]*:(\/\/)?)(.*)/
15
+ parts = /^([a-zA-Z0-9]*:(\/\/)?)(.*)/.match @expanded_uri
16
16
  if parts
17
17
  prefix = parts[1]
18
18
  @path = parts[3]
19
- uri = URI(prefix + URI.encode(@path, URI_ENCODE_CHARS))
19
+ uri = URI(prefix + Source.encode_path_for_uri(@path))
20
20
  else
21
- uri = URI(URI.encode @expanded_uri, URI_ENCODE_CHARS)
21
+ uri = URI(Source.encode_path_for_uri @path)
22
22
  @path = uri.path
23
23
  end
24
24
 
@@ -30,7 +30,7 @@ class Maildir < Source
30
30
  # sync by default if not specified
31
31
  @sync_back = true if @sync_back.nil?
32
32
 
33
- @dir = URI.decode uri.path
33
+ @dir = URI.decode_www_form_component uri.path
34
34
  @labels = Set.new(labels || [])
35
35
  @mutex = Mutex.new
36
36
  @ctimes = { 'cur' => Time.at(0), 'new' => Time.at(0) }
data/lib/sup/mbox.rb CHANGED
@@ -19,13 +19,13 @@ class MBox < Source
19
19
  case uri_or_fp
20
20
  when String
21
21
  @expanded_uri = Source.expand_filesystem_uri(uri_or_fp)
22
- parts = @expanded_uri.match /^([a-zA-Z0-9]*:(\/\/)?)(.*)/
22
+ parts = /^([a-zA-Z0-9]*:(\/\/)?)(.*)/.match @expanded_uri
23
23
  if parts
24
24
  prefix = parts[1]
25
25
  @path = parts[3]
26
- uri = URI(prefix + URI.encode(@path, URI_ENCODE_CHARS))
26
+ uri = URI(prefix + Source.encode_path_for_uri(@path))
27
27
  else
28
- uri = URI(URI.encode @expanded_uri, URI_ENCODE_CHARS)
28
+ uri = URI(Source.encode_path_for_uri @expanded_uri)
29
29
  @path = uri.path
30
30
  end
31
31
 
@@ -36,7 +36,7 @@ class MBox < Source
36
36
  else
37
37
  @f = uri_or_fp
38
38
  @path = uri_or_fp.path
39
- @expanded_uri = "mbox://#{URI.encode @path, URI_ENCODE_CHARS}"
39
+ @expanded_uri = "mbox://#{Source.encode_path_for_uri @path}"
40
40
  end
41
41
 
42
42
  super uri_or_fp, usual, archived, id
data/lib/sup/message.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'time'
4
+ require 'string-scrub' if /^2\.0\./ =~ RUBY_VERSION
4
5
 
5
6
  module Redwood
6
7
 
@@ -71,9 +72,9 @@ class Message
71
72
  return unless v
72
73
  return v unless v.is_a? String
73
74
  return unless v.size < MAX_HEADER_VALUE_SIZE # avoid regex blowup on spam
74
- d = v.dup
75
- d = d.transcode($encoding, 'ASCII')
76
- Rfc2047.decode_to $encoding, d
75
+ ## Header values should be either 7-bit with RFC2047-encoded words
76
+ ## or UTF-8 as per RFC6532. Replace any invalid high bytes with U+FFFD.
77
+ Rfc2047.decode_to $encoding, v.dup.force_encoding(Encoding::UTF_8).scrub
77
78
  end
78
79
 
79
80
  def parse_header encoded_header
@@ -104,7 +105,7 @@ class Message
104
105
  when String
105
106
  begin
106
107
  Time.parse date
107
- rescue ArgumentError => e
108
+ rescue ArgumentError
108
109
  #debug "faking mangled date header for #{@id} (orig #{header['date'].inspect} gave error: #{e.message})"
109
110
  Time.now
110
111
  end
@@ -309,7 +310,7 @@ EOS
309
310
  end
310
311
 
311
312
  def each_raw_message_line &b
312
- location.each_raw_message_line &b
313
+ location.each_raw_message_line(&b)
313
314
  end
314
315
 
315
316
  def sync_back
@@ -128,7 +128,16 @@ EOS
128
128
 
129
129
  text = case @content_type
130
130
  when /^text\/plain\b/
131
- @raw_content.force_encoding(encoded_content.charset || 'US-ASCII')
131
+ if /^UTF-7$/i =~ encoded_content.charset
132
+ @raw_content.decode_utf7
133
+ else
134
+ begin
135
+ charset = Encoding.find(encoded_content.charset || 'US-ASCII')
136
+ rescue ArgumentError
137
+ charset = 'US-ASCII'
138
+ end
139
+ @raw_content.force_encoding(charset)
140
+ end
132
141
  else
133
142
  HookManager.run "mime-decode", :content_type => @content_type,
134
143
  :filename => lambda { write_to_disk },
@@ -274,24 +283,19 @@ EOS
274
283
  class EnclosedMessage
275
284
  attr_reader :lines
276
285
  def initialize from, to, cc, date, subj
277
- @from = from ? "unknown sender" : from.full_address
278
- @to = to ? "" : to.map { |p| p.full_address }.join(", ")
279
- @cc = cc ? "" : cc.map { |p| p.full_address }.join(", ")
280
- if date
281
- @date = date.rfc822
282
- else
283
- @date = ""
284
- end
285
-
286
+ @from = !from ? "unknown sender" : from.full_address
287
+ @to = !to ? "" : to.map { |p| p.full_address }.join(", ")
288
+ @cc = !cc ? "" : cc.map { |p| p.full_address }.join(", ")
289
+ @date = !date ? "" : date.rfc822
286
290
  @subj = subj
287
-
288
- @lines = "\nFrom: #{from}\n"
289
- @lines += "To: #{to}\n"
290
- if !cc.empty?
291
- @lines += "Cc: #{cc}\n"
292
- end
293
- @lines += "Date: #{date}\n"
294
- @lines += "Subject: #{subj}\n\n"
291
+ @lines = [
292
+ "From: #{@from}",
293
+ "To: #{@to}",
294
+ "Cc: #{@cc}",
295
+ "Date: #{@date}",
296
+ "Subject: #{@subj}"
297
+ ]
298
+ @lines.delete_if{ |line| line == 'Cc: ' }
295
299
  end
296
300
 
297
301
  def inlineable?; false end
@@ -302,7 +306,11 @@ EOS
302
306
  def viewable?; false end
303
307
 
304
308
  def patina_color; :generic_notice_patina_color end
305
- def patina_text; "Begin enclosed message sent on #{@date}" end
309
+ def patina_text
310
+ "Begin enclosed message" + (
311
+ @date == "" ? "" : " sent on #{@date}"
312
+ )
313
+ end
306
314
 
307
315
  def color; :quote_color end
308
316
  end
@@ -26,7 +26,6 @@ class CompletionMode < ScrollMode
26
26
  private
27
27
 
28
28
  def update_lines
29
- width = buffer.content_width
30
29
  max_length = @list.max_of { |s| s.length }
31
30
  num_per = [1, buffer.content_width / (max_length + INTERSTITIAL.length)].max
32
31
  @lines = [@header].compact