sup 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +1 -1
  4. data/CONTRIBUTORS +15 -12
  5. data/History.txt +16 -0
  6. data/ReleaseNotes +7 -0
  7. data/bin/sup +10 -24
  8. data/bin/sup-sync-back-maildir +1 -1
  9. data/contrib/completion/_sup.bash +102 -0
  10. data/lib/sup.rb +7 -7
  11. data/lib/sup/colormap.rb +5 -2
  12. data/lib/sup/contact.rb +4 -2
  13. data/lib/sup/crypto.rb +34 -2
  14. data/lib/sup/draft.rb +7 -7
  15. data/lib/sup/hook.rb +1 -1
  16. data/lib/sup/index.rb +2 -2
  17. data/lib/sup/label.rb +1 -1
  18. data/lib/sup/maildir.rb +2 -2
  19. data/lib/sup/mbox.rb +2 -2
  20. data/lib/sup/message.rb +6 -0
  21. data/lib/sup/message_chunks.rb +4 -2
  22. data/lib/sup/mode.rb +31 -26
  23. data/lib/sup/modes/edit_message_mode.rb +1 -1
  24. data/lib/sup/modes/forward_mode.rb +22 -3
  25. data/lib/sup/modes/line_cursor_mode.rb +1 -1
  26. data/lib/sup/modes/text_mode.rb +6 -1
  27. data/lib/sup/modes/thread_index_mode.rb +1 -1
  28. data/lib/sup/modes/thread_view_mode.rb +47 -6
  29. data/lib/sup/person.rb +68 -61
  30. data/lib/sup/search.rb +1 -1
  31. data/lib/sup/sent.rb +1 -1
  32. data/lib/sup/util/locale_fiddler.rb +24 -0
  33. data/lib/sup/version.rb +1 -1
  34. data/sup.gemspec +4 -3
  35. data/test/integration/test_maildir.rb +1 -1
  36. data/test/integration/test_mbox.rb +1 -1
  37. data/test/test_crypto.rb +1 -1
  38. data/test/test_header_parsing.rb +1 -1
  39. data/test/test_message.rb +77 -19
  40. data/test/test_messages_dir.rb +1 -19
  41. data/test/test_yaml_regressions.rb +1 -1
  42. data/test/unit/fixtures/contacts.txt +1 -0
  43. data/test/unit/test_contact.rb +33 -0
  44. data/test/unit/test_locale_fiddler.rb +15 -0
  45. data/test/unit/test_person.rb +37 -0
  46. metadata +31 -7
@@ -12,7 +12,7 @@ class SearchManager
12
12
  def initialize fn
13
13
  @fn = fn
14
14
  @searches = {}
15
- if File.exists? fn
15
+ if File.exist? fn
16
16
  IO.foreach(fn) do |l|
17
17
  l =~ /^([^:]*): (.*)$/ or raise "can't parse #{fn} line #{l.inspect}"
18
18
  @searches[$1] = $2
@@ -40,7 +40,7 @@ class SentLoader < MBox
40
40
 
41
41
  def initialize
42
42
  @filename = Redwood::SENT_FN
43
- File.open(@filename, "w") { } unless File.exists? @filename
43
+ File.open(@filename, "w") { } unless File.exist? @filename
44
44
  super "mbox://" + @filename, true, $config[:archive_sent]
45
45
  end
46
46
 
@@ -0,0 +1,24 @@
1
+ ## the following magic enables wide characters when used with a ruby
2
+ ## ncurses.so that's been compiled against libncursesw. (note the w.) why
3
+ ## this works, i have no idea. much like pretty much every aspect of
4
+ ## dealing with curses. cargo cult programming at its best.
5
+ require 'fiddle'
6
+ require 'fiddle/import'
7
+
8
+ module LocaleFiddler
9
+ extend Fiddle::Importer
10
+
11
+ SETLOCALE_LIB = case RbConfig::CONFIG['arch']
12
+ when /darwin/; "libc.dylib"
13
+ when /cygwin/; "cygwin1.dll"
14
+ when /freebsd/; "libc.so.7"
15
+ else; "libc.so.6"
16
+ end
17
+
18
+ dlload SETLOCALE_LIB
19
+ extern "char *setlocale(int, char const *)"
20
+
21
+ def setlocale(type, string)
22
+ LocaleFiddler.setlocale(type, string)
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module Redwood
2
- VERSION = "0.20.0"
2
+ VERSION = "0.21.0"
3
3
  end
@@ -38,7 +38,7 @@ SUP: please note that our old mailing lists have been shut down,
38
38
  s.require_paths = ["lib"]
39
39
  s.extra_rdoc_files = Dir.glob("man/*")
40
40
 
41
- s.required_ruby_version = '>= 1.9.3'
41
+ s.required_ruby_version = '>= 2.0.0'
42
42
 
43
43
  # this is here to support skipping the xapian-ruby installation on OpenBSD
44
44
  # because the xapian-ruby gem doesn't install on OpenBSD, you must install
@@ -62,8 +62,9 @@ SUP: please note that our old mailing lists have been shut down,
62
62
 
63
63
  s.add_development_dependency "bundler", "~> 1.3"
64
64
  s.add_development_dependency "rake"
65
- s.add_development_dependency "minitest", "~> 4.7"
66
- s.add_development_dependency "rr", "~> 1.0.5"
65
+ s.add_development_dependency 'minitest', '~> 5.5.1'
66
+ s.add_development_dependency "rr", "~> 1.1"
67
67
  s.add_development_dependency "gpgme", ">= 2.0.2"
68
+ s.add_development_dependency "pry"
68
69
 
69
70
  end
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- class TestMaildir < MiniTest::Unit::TestCase
3
+ class TestMaildir < Minitest::Test
4
4
 
5
5
  def setup
6
6
  @path = Dir.mktmpdir
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- class TestMbox < MiniTest::Unit::TestCase
3
+ class TestMbox < MiniTest::Test
4
4
 
5
5
  def setup
6
6
  @path = Dir.mktmpdir
@@ -25,7 +25,7 @@ require 'tmpdir'
25
25
 
26
26
  module Redwood
27
27
 
28
- class TestCryptoManager < ::Minitest::Unit::TestCase
28
+ class TestCryptoManager < Minitest::Test
29
29
 
30
30
  def setup
31
31
  @from_email = 'sup-test-1@foo.bar'
@@ -6,7 +6,7 @@ require 'stringio'
6
6
 
7
7
  include Redwood
8
8
 
9
- class TestMBoxParsing < Minitest::Unit::TestCase
9
+ class TestMBoxParsing < Minitest::Test
10
10
 
11
11
  def setup
12
12
  @path = Dir.mktmpdir
@@ -6,27 +6,9 @@ require 'stringio'
6
6
 
7
7
  require 'dummy_source'
8
8
 
9
- # override File.exists? to make it work with StringIO for testing.
10
- # FIXME: do aliasing to avoid breaking this when sup moves from
11
- # File.exists? to File.exist?
12
-
13
- class File
14
-
15
- def File.exists? file
16
- # puts "fake File::exists?"
17
-
18
- if file.is_a?(StringIO)
19
- return false
20
- end
21
- # use the different function
22
- File.exist?(file)
23
- end
24
-
25
- end
26
-
27
9
  module Redwood
28
10
 
29
- class TestMessage < ::Minitest::Unit::TestCase
11
+ class TestMessage < Minitest::Test
30
12
 
31
13
  def setup
32
14
  @path = Dir.mktmpdir
@@ -520,6 +502,82 @@ EOS
520
502
 
521
503
  end
522
504
 
505
+ def test_malicious_attachment_names
506
+
507
+
508
+ message = <<EOS
509
+ From: Matthieu Rakotojaona <matthieu.rakotojaona@gmail.com>
510
+ To: reply+0007a7cb7174d1d188fcd420fce83e0f68fe03fc7416cdae92cf0000000110ce4efd92a169ce033d18e1 <reply+0007a7cb7174d1d188fcd420fce83e0f68fe03fc7416cdae92cf0000000110ce4efd92a169ce033d18e1@reply.github.com>
511
+ Subject: Re: [sup] Attachment saving and special characters in filenames (#378)
512
+ In-reply-to: <sup-heliotrope/sup/issues/378@github.com>
513
+ References: <sup-heliotrope/sup/issues/378@github.com>
514
+ X-pgp-key: http://otokar.looc2011.eu/static/matthieu.rakotojaona.asc
515
+ Date: Wed, 14 Jan 2015 22:13:37 +0100
516
+ Message-Id: <1421269972-sup-5245@kpad>
517
+ User-Agent: Sup/git
518
+ Content-Transfer-Encoding: 8bit
519
+ MIME-Version: 1.0
520
+ Content-Type: multipart/mixed; boundary="=-1421270017-526778-1064-1628-1-="
521
+
522
+
523
+ --=-1421270017-526778-1064-1628-1-=
524
+ Content-Type: text/plain; charset=UTF-8
525
+ Content-Disposition: inline
526
+
527
+ Excerpts from Felix Kaiser's message of 2015-01-14 16:36:29 +0100:
528
+ > When saving attachments, sup should replace special characters when suggesting a filename to save the attachment to.
529
+ >
530
+ > I just got an attachment with a name like "foo/2.pdf". sup suggests saving it to /home/fxkr/foo/2.pdf (and fails to save it, of course, if /home/fxkr/foo isn't a directory).
531
+ >
532
+ > I haven't tested the "Save All" feature, but I hope nothing bad happens when there's an attachment called "../../../../../../../home/fxkr/.bashrc" ;-)
533
+ >
534
+ > ---
535
+ > Reply to this email directly or view it on GitHub:
536
+ > https://github.com/sup-heliotrope/sup/issues/378
537
+
538
+ For tests, here's an email with an attachment filename set to
539
+ sup/.travis.yml (really, this time)
540
+
541
+ --
542
+ Matthieu Rakotojaona
543
+
544
+ --=-1421270017-526778-1064-1628-1-=
545
+ Content-Disposition: attachment; filename="sup/.travis.yml"
546
+ Content-Type: text/x-yaml; name="sup/.travis.yml"
547
+ Content-Transfer-Encoding: 8bit
548
+
549
+ language: ruby
550
+
551
+ rvm:
552
+ - 2.1.1
553
+ - 2.0.0
554
+ - 1.9.3
555
+
556
+ before_install:
557
+ - sudo apt-get update -qq
558
+ - sudo apt-get install -qq uuid-dev uuid libncursesw5-dev libncursesw5 gnupg2 pandoc
559
+ - git submodule update --init --recursive
560
+
561
+ script: bundle exec rake travis
562
+
563
+ --=-1421270017-526778-1064-1628-1-=--
564
+ EOS
565
+
566
+ source = DummySource.new("sup-test://test_blank_header_lines")
567
+ source.messages = [ message ]
568
+ source_info = 0
569
+
570
+ sup_message = Message.build_from_source(source, source_info)
571
+ chunks = sup_message.load_from_source!
572
+
573
+ # See if attachment filenames can be safely used for saving.
574
+ # We do that by verifying that any folder-related character (/ or \)
575
+ # are not interpreted: the filename must not be interpreted into a
576
+ # path.
577
+ fn = chunks[3].safe_filename
578
+ assert_equal(fn, File.basename(fn))
579
+
580
+ end
523
581
  # TODO: test different error cases, malformed messages etc.
524
582
 
525
583
  # TODO: test different quoting styles, see that they are all divided
@@ -6,27 +6,9 @@ require 'stringio'
6
6
 
7
7
  require 'dummy_source'
8
8
 
9
- # override File.exists? to make it work with StringIO for testing.
10
- # FIXME: do aliasing to avoid breaking this when sup moves from
11
- # File.exists? to File.exist?
12
-
13
- class File
14
-
15
- def File.exists? file
16
- # puts "fake File::exists?"
17
-
18
- if file.is_a?(StringIO)
19
- return false
20
- end
21
- # use the different function
22
- File.exist?(file)
23
- end
24
-
25
- end
26
-
27
9
  module Redwood
28
10
 
29
- class TestMessagesDir < ::Minitest::Unit::TestCase
11
+ class TestMessagesDir < ::Minitest::Test
30
12
 
31
13
  def setup
32
14
  @path = Dir.mktmpdir
@@ -6,7 +6,7 @@ require 'yaml'
6
6
  require 'sup'
7
7
 
8
8
  module Redwood
9
- class TestYamlRegressions < ::Minitest::Unit::TestCase
9
+ class TestYamlRegressions < ::Minitest::Test
10
10
  def test_yamling_hash
11
11
  hsh = {:foo => 42}
12
12
  reloaded = YAML.load(hsh.to_yaml)
@@ -0,0 +1 @@
1
+ RC: Random Contact <random_dude@gmail.com>
@@ -0,0 +1,33 @@
1
+ require 'test_helper'
2
+ require 'sup/contact'
3
+
4
+ module Redwood
5
+
6
+ class TestContact < Minitest::Test
7
+ def setup
8
+ @contact = ContactManager.init(File.expand_path("../fixtures/contacts.txt", __FILE__))
9
+ @person = Person.new "Terrible Name", "terrible@name.com"
10
+ end
11
+
12
+ def teardown
13
+ runner = Redwood.const_get "ContactManager".to_sym
14
+ runner.deinstantiate!
15
+ end
16
+
17
+ def test_contact_manager
18
+ assert @contact
19
+ ## 1 contact is imported from the fixture file.
20
+ assert_equal 1, @contact.contacts.count
21
+ assert_equal @contact.contact_for("RC").name, "Random Contact"
22
+
23
+ assert_nil @contact.contact_for "TN"
24
+ @contact.update_alias @person, "TN"
25
+
26
+ assert @contact.is_aliased_contact?(@person)
27
+ assert_equal @person, @contact.contact_for("TN")
28
+
29
+ assert_equal "TN", @contact.alias_for(@person)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+ require 'sup/util/locale_fiddler'
3
+
4
+ class TestFiddle < ::Minitest::Unit::TestCase
5
+ # TODO this is a silly test
6
+ def test_fiddle_set_locale
7
+ before = LocaleDummy.setlocale(6, nil).to_s
8
+ after = LocaleDummy.setlocale(6, "").to_s
9
+ assert(before != after, "Expected locale to be fiddled with")
10
+ end
11
+ end
12
+
13
+ class LocaleDummy
14
+ extend LocaleFiddler
15
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+ require 'sup'
3
+
4
+ module Redwood
5
+
6
+ class TestPerson < Minitest::Test
7
+ def setup
8
+ @person = Person.new("Thomassen, Bob", "bob@thomassen.com")
9
+ @no_name = Person.new(nil, "alice@alice.com")
10
+ end
11
+
12
+ def test_email_must_be_supplied
13
+ assert_raises (ArgumentError) { Person.new("Alice", nil) }
14
+ end
15
+
16
+ def test_to_string
17
+ assert_equal "Thomassen, Bob <bob@thomassen.com>", "#{@person}"
18
+ assert_equal "alice@alice.com", "#{@no_name}"
19
+ end
20
+
21
+ def test_shortname
22
+ assert_equal "Bob", @person.shortname
23
+ assert_equal "alice@alice.com", @no_name.shortname
24
+ end
25
+
26
+ def test_mediumname
27
+ assert_equal "Thomassen, Bob", @person.mediumname
28
+ assert_equal "alice@alice.com", @no_name.mediumname
29
+ end
30
+
31
+ def test_fullname
32
+ assert_equal "\"Thomassen, Bob\" <bob@thomassen.com>", @person.full_address
33
+ assert_equal "alice@alice.com", @no_name.full_address
34
+ end
35
+ end
36
+
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Morgan
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-10-06 00:00:00.000000000 Z
14
+ date: 2015-02-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: ncursesw
@@ -173,28 +173,28 @@ dependencies:
173
173
  requirements:
174
174
  - - "~>"
175
175
  - !ruby/object:Gem::Version
176
- version: '4.7'
176
+ version: 5.5.1
177
177
  type: :development
178
178
  prerelease: false
179
179
  version_requirements: !ruby/object:Gem::Requirement
180
180
  requirements:
181
181
  - - "~>"
182
182
  - !ruby/object:Gem::Version
183
- version: '4.7'
183
+ version: 5.5.1
184
184
  - !ruby/object:Gem::Dependency
185
185
  name: rr
186
186
  requirement: !ruby/object:Gem::Requirement
187
187
  requirements:
188
188
  - - "~>"
189
189
  - !ruby/object:Gem::Version
190
- version: 1.0.5
190
+ version: '1.1'
191
191
  type: :development
192
192
  prerelease: false
193
193
  version_requirements: !ruby/object:Gem::Requirement
194
194
  requirements:
195
195
  - - "~>"
196
196
  - !ruby/object:Gem::Version
197
- version: 1.0.5
197
+ version: '1.1'
198
198
  - !ruby/object:Gem::Dependency
199
199
  name: gpgme
200
200
  requirement: !ruby/object:Gem::Requirement
@@ -209,6 +209,20 @@ dependencies:
209
209
  - - ">="
210
210
  - !ruby/object:Gem::Version
211
211
  version: 2.0.2
212
+ - !ruby/object:Gem::Dependency
213
+ name: pry
214
+ requirement: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ - - ">="
217
+ - !ruby/object:Gem::Version
218
+ version: '0'
219
+ type: :development
220
+ prerelease: false
221
+ version_requirements: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
212
226
  description: |2
213
227
  Sup is a console-based email client for people with a lot of email.
214
228
 
@@ -266,6 +280,7 @@ files:
266
280
  - bin/sup-sync-back-maildir
267
281
  - bin/sup-tweak-labels
268
282
  - contrib/colorpicker.rb
283
+ - contrib/completion/_sup.bash
269
284
  - contrib/completion/_sup.zsh
270
285
  - devel/console.sh
271
286
  - devel/count-loc.sh
@@ -336,6 +351,7 @@ files:
336
351
  - lib/sup/undo.rb
337
352
  - lib/sup/update.rb
338
353
  - lib/sup/util.rb
354
+ - lib/sup/util/locale_fiddler.rb
339
355
  - lib/sup/util/ncurses.rb
340
356
  - lib/sup/util/path.rb
341
357
  - lib/sup/util/query.rb
@@ -375,8 +391,12 @@ files:
375
391
  - test/test_messages_dir.rb
376
392
  - test/test_yaml_migration.rb
377
393
  - test/test_yaml_regressions.rb
394
+ - test/unit/fixtures/contacts.txt
378
395
  - test/unit/service/test_label_service.rb
396
+ - test/unit/test_contact.rb
379
397
  - test/unit/test_horizontal_selector.rb
398
+ - test/unit/test_locale_fiddler.rb
399
+ - test/unit/test_person.rb
380
400
  - test/unit/util/test_query.rb
381
401
  - test/unit/util/test_string.rb
382
402
  - test/unit/util/test_uri.rb
@@ -400,7 +420,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
400
420
  requirements:
401
421
  - - ">="
402
422
  - !ruby/object:Gem::Version
403
- version: 1.9.3
423
+ version: 2.0.0
404
424
  required_rubygems_version: !ruby/object:Gem::Requirement
405
425
  requirements:
406
426
  - - ">="
@@ -436,8 +456,12 @@ test_files:
436
456
  - test/test_messages_dir.rb
437
457
  - test/test_yaml_migration.rb
438
458
  - test/test_yaml_regressions.rb
459
+ - test/unit/fixtures/contacts.txt
439
460
  - test/unit/service/test_label_service.rb
461
+ - test/unit/test_contact.rb
440
462
  - test/unit/test_horizontal_selector.rb
463
+ - test/unit/test_locale_fiddler.rb
464
+ - test/unit/test_person.rb
441
465
  - test/unit/util/test_query.rb
442
466
  - test/unit/util/test_string.rb
443
467
  - test/unit/util/test_uri.rb