sup 0.13.2.1 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sup might be problematic. Click here for more details.

@@ -168,6 +168,16 @@ private
168
168
  else # trailing spaces
169
169
  v + (" " * (x - @question.length - v.length))
170
170
  end
171
+
172
+ # ncurses returns a ASCII-8BIT (binary) string, which
173
+ # bytes presumably are of current charset encoding. we force_encoding
174
+ # so that the char representation / string is tagged will be the
175
+ # system locale and also hopefully the terminal/input encoding. an
176
+ # incorrectly configured terminal encoding (not matching the system
177
+ # encoding) will produce erronous results, but will also do that for
178
+ # a log of other programs since it is impossible to detect which is
179
+ # which and what encoding the inputted byte chars are supposed to have.
180
+ v.force_encoding($encoding).fix_encoding
171
181
  end
172
182
 
173
183
  def remove_extra_space
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'thread'
2
4
  require 'lockfile'
3
5
  require 'mime/types'
@@ -5,7 +7,7 @@ require 'pathname'
5
7
  require 'set'
6
8
  require 'enumerator'
7
9
  require 'benchmark'
8
- require 'iconv'
10
+ require 'unicode'
9
11
 
10
12
  ## time for some monkeypatching!
11
13
  class Symbol
@@ -31,7 +33,7 @@ class Lockfile
31
33
  def dump_lock_id lock_id = @lock_id
32
34
  "host: %s\npid: %s\nppid: %s\ntime: %s\nuser: %s\npname: %s\n" %
33
35
  lock_id.values_at('host','pid','ppid','time','user', 'pname')
34
- end
36
+ end
35
37
 
36
38
  def lockinfo_on_disk
37
39
  h = load_lock_id IO.read(path)
@@ -114,6 +116,25 @@ module RMail
114
116
  end
115
117
 
116
118
  class Header
119
+
120
+ # Convert to ASCII before trying to match with regexp
121
+ class Field
122
+
123
+ EXTRACT_FIELD_NAME_RE = /\A([^\x00-\x1f\x7f-\xff :]+):\s*/no
124
+
125
+ class << self
126
+ def parse(field)
127
+ field = field.dup.to_s
128
+ field = field.fix_encoding.ascii
129
+ if field =~ EXTRACT_FIELD_NAME_RE
130
+ [ $1, $'.chomp ]
131
+ else
132
+ [ "", Field.value_strip(field) ]
133
+ end
134
+ end
135
+ end
136
+ end
137
+
117
138
  ## Be more cautious about invalid content-type headers
118
139
  ## the original RMail code calls
119
140
  ## value.strip.split(/\s*;\s*/)[0].downcase
@@ -234,14 +255,14 @@ class Object
234
255
  end
235
256
 
236
257
  class String
237
- ## nasty multibyte hack for ruby 1.8. if it's utf-8, split into chars using
238
- ## the utf8 regex and count those. otherwise, use the byte length.
239
258
  def display_length
240
- if RUBY_VERSION < '1.9.1' && ($encoding == "UTF-8" || $encoding == "utf8")
241
- # scan hack is somewhat slow, worth trying to cache
242
- @display_length ||= scan(/./u).size
243
- else
244
- size
259
+ @display_length ||= Unicode.width(self, false)
260
+ end
261
+
262
+ def slice_by_display_length len
263
+ each_char.each_with_object "" do |c, buffer|
264
+ len -= c.display_length
265
+ buffer << c if len >= 0
245
266
  end
246
267
  end
247
268
 
@@ -328,20 +349,69 @@ class String
328
349
  def wrap len
329
350
  ret = []
330
351
  s = self
331
- while s.length > len
332
- cut = s[0 ... len].rindex(/\s/)
352
+ while s.display_length > len
353
+ cut = s.slice_by_display_length(len).rindex(/\s/)
333
354
  if cut
334
355
  ret << s[0 ... cut]
335
356
  s = s[(cut + 1) .. -1]
336
357
  else
337
- ret << s[0 ... len]
338
- s = s[len .. -1]
358
+ ret << s.slice_by_display_length(len)
359
+ s = s[ret.last.length .. -1]
339
360
  end
340
361
  end
341
362
  ret << s
342
363
  end
343
364
 
365
+ # Fix the damn string! make sure it is valid utf-8, then convert to
366
+ # user encoding.
367
+ #
368
+ # Not Ruby 1.8 compatible
369
+ def fix_encoding
370
+ # first try to encode to utf-8 from whatever current encoding
371
+ encode!('UTF-8', :invalid => :replace, :undef => :replace)
372
+
373
+ # do this anyway in case string is set to be UTF-8, encoding to
374
+ # something else (UTF-16 which can fully represent UTF-8) and back
375
+ # ensures invalid chars are replaced.
376
+ encode!('UTF-16', 'UTF-8', :invalid => :replace, :undef => :replace)
377
+ encode!('UTF-8', 'UTF-16', :invalid => :replace, :undef => :replace)
378
+
379
+ fail "Could not create valid UTF-8 string out of: '#{self.to_s}'." unless valid_encoding?
380
+
381
+ # now convert to $encoding
382
+ encode!($encoding, :invalid => :replace, :undef => :replace)
383
+
384
+ fail "Could not create valid #{$encoding.inspect} string out of: '#{self.to_s}'." unless valid_encoding?
385
+
386
+ self
387
+ end
388
+
389
+ # transcode the string if original encoding is know
390
+ # fix if broken.
391
+ #
392
+ # Not Ruby 1.8 compatible
393
+ def transcode to_encoding, from_encoding
394
+ begin
395
+ encode!(to_encoding, from_encoding, :invalid => :replace, :undef => :replace)
396
+
397
+ unless valid_encoding?
398
+ # fix encoding (through UTF-8)
399
+ encode!('UTF-16', from_encoding, :invalid => :replace, :undef => :replace)
400
+ encode!(to_encoding, 'UTF-16', :invalid => :replace, :undef => :replace)
401
+ end
402
+
403
+ rescue Encoding::ConverterNotFoundError
404
+ debug "Encoding converter not found for #{from_encoding.inspect} or #{to_encoding.inspect}, fixing string: '#{self.to_s}', but expect weird characters."
405
+ fix_encoding
406
+ end
407
+
408
+ fail "Could not create valid #{to_encoding.inspect} string out of: '#{self.to_s}'." unless valid_encoding?
409
+
410
+ self
411
+ end
412
+
344
413
  def normalize_whitespace
414
+ fix_encoding
345
415
  gsub(/\t/, " ").gsub(/\r/, "")
346
416
  end
347
417
 
@@ -383,12 +453,8 @@ class String
383
453
  out << b.chr
384
454
  end
385
455
  end
386
- out.force_encoding Encoding::UTF_8 if out.respond_to? :force_encoding
387
- out
388
- end
389
-
390
- def transcode src_encoding=$encoding
391
- Iconv.easy_decode $encoding, src_encoding, self
456
+ out = out.fix_encoding # this should now be an utf-8 string of ascii
457
+ # compat chars.
392
458
  end
393
459
 
394
460
  unless method_defined? :ascii_only?
@@ -659,27 +725,3 @@ class FinishLine
659
725
  end
660
726
  end
661
727
 
662
- class Iconv
663
- def self.easy_decode target, orig_charset, text
664
- if text.respond_to? :force_encoding
665
- text = text.dup
666
- text.force_encoding Encoding::BINARY
667
- end
668
- charset = case orig_charset
669
- when /UTF[-_ ]?8/i then "utf-8"
670
- when /(iso[-_ ])?latin[-_ ]?1$/i then "ISO-8859-1"
671
- when /iso[-_ ]?8859[-_ ]?15/i then 'ISO-8859-15'
672
- when /unicode[-_ ]1[-_ ]1[-_ ]utf[-_]7/i then "utf-7"
673
- when /^euc$/i then 'EUC-JP' # XXX try them all?
674
- when /^(x-unknown|unknown[-_ ]?8bit|ascii[-_ ]?7[-_ ]?bit)$/i then 'ASCII'
675
- else orig_charset
676
- end
677
-
678
- begin
679
- returning(Iconv.iconv(target + "//IGNORE", charset, text + " ").join[0 .. -2]) { |str| str.check }
680
- rescue Errno::EINVAL, Iconv::InvalidEncoding, Iconv::InvalidCharacter, Iconv::IllegalSequence, String::CheckError
681
- debug "couldn't transcode text from #{orig_charset} (#{charset}) to #{target} (#{text[0 ... 20].inspect}...): got #{$!.class} (#{$!.message})"
682
- text.ascii
683
- end
684
- end
685
- end
@@ -0,0 +1,14 @@
1
+ module Redwood
2
+ module Util
3
+ module Query
4
+ class QueryDescriptionError < ArgumentError; end
5
+
6
+ def self.describe query
7
+ d = query.description.force_encoding("UTF-8")
8
+
9
+ raise QueryDescriptionError.new(d) unless d.valid_encoding?
10
+ return d
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Redwood
2
- VERSION = "0.13.2.1"
2
+ VERSION = "0.14.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2.1
4
+ version: 0.14.0
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 13
9
- - 2
10
- - 1
11
- hash: 3165895177967591158
8
+ - 14
9
+ - 0
10
+ hash: 3076317061437341881
12
11
  platform: ruby
13
12
  authors:
14
13
  - William Morgan
@@ -18,21 +17,16 @@ authors:
18
17
  autorequire:
19
18
  bindir: bin
20
19
  cert_chain: []
21
- date: 2013-10-29 00:00:00.000000000 Z
20
+ date: 2013-08-15 00:00:00.000000000 Z
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
24
- name: xapian-full-alaveteli
23
+ name: xapian-ruby
25
24
  requirement: !ruby/object:Gem::Requirement
26
25
  none: false
27
26
  requirements:
28
27
  - - ~>
29
28
  - !ruby/object:Gem::Version
30
- version: '1.2'
31
- prerelease:
32
- segments:
33
- - 1
34
- - 2
35
- hash: 868825659676859863
29
+ version: 1.2.15
36
30
  type: :runtime
37
31
  prerelease: false
38
32
  version_requirements: !ruby/object:Gem::Requirement
@@ -40,56 +34,23 @@ dependencies:
40
34
  requirements:
41
35
  - - ~>
42
36
  - !ruby/object:Gem::Version
43
- version: '1.2'
44
- prerelease:
45
- segments:
46
- - 1
47
- - 2
48
- hash: 868825659676859863
37
+ version: 1.2.15
49
38
  - !ruby/object:Gem::Dependency
50
39
  name: ncursesw-sup
51
40
  requirement: !ruby/object:Gem::Requirement
52
41
  none: false
53
42
  requirements:
54
43
  - - ~>
55
- - !ruby/object:Gem::Version
56
- version: '1.3'
57
- prerelease:
58
- segments:
59
- - 1
60
- - 3
61
- hash: 507327302350482719
62
- - - ! '>='
63
44
  - !ruby/object:Gem::Version
64
45
  version: 1.3.1
65
- prerelease:
66
- segments:
67
- - 1
68
- - 3
69
- - 1
70
- hash: 3105951872946229212
71
46
  type: :runtime
72
47
  prerelease: false
73
48
  version_requirements: !ruby/object:Gem::Requirement
74
49
  none: false
75
50
  requirements:
76
51
  - - ~>
77
- - !ruby/object:Gem::Version
78
- version: '1.3'
79
- prerelease:
80
- segments:
81
- - 1
82
- - 3
83
- hash: 507327302350482719
84
- - - ! '>='
85
52
  - !ruby/object:Gem::Version
86
53
  version: 1.3.1
87
- prerelease:
88
- segments:
89
- - 1
90
- - 3
91
- - 1
92
- hash: 3105951872946229212
93
54
  - !ruby/object:Gem::Dependency
94
55
  name: rmail
95
56
  requirement: !ruby/object:Gem::Requirement
@@ -98,11 +59,6 @@ dependencies:
98
59
  - - ! '>='
99
60
  - !ruby/object:Gem::Version
100
61
  version: '0.17'
101
- prerelease:
102
- segments:
103
- - 0
104
- - 17
105
- hash: 3437085760670918924
106
62
  type: :runtime
107
63
  prerelease: false
108
64
  version_requirements: !ruby/object:Gem::Requirement
@@ -111,35 +67,22 @@ dependencies:
111
67
  - - ! '>='
112
68
  - !ruby/object:Gem::Version
113
69
  version: '0.17'
114
- prerelease:
115
- segments:
116
- - 0
117
- - 17
118
- hash: 3437085760670918924
119
70
  - !ruby/object:Gem::Dependency
120
71
  name: highline
121
72
  requirement: !ruby/object:Gem::Requirement
122
- none: true
73
+ none: false
123
74
  requirements:
124
75
  - - ! '>='
125
76
  - !ruby/object:Gem::Version
126
77
  version: '0'
127
- prerelease:
128
- segments:
129
- - 0
130
- hash: 780439954604562836
131
78
  type: :runtime
132
79
  prerelease: false
133
80
  version_requirements: !ruby/object:Gem::Requirement
134
- none: true
81
+ none: false
135
82
  requirements:
136
83
  - - ! '>='
137
84
  - !ruby/object:Gem::Version
138
85
  version: '0'
139
- prerelease:
140
- segments:
141
- - 0
142
- hash: 780439954604562836
143
86
  - !ruby/object:Gem::Dependency
144
87
  name: trollop
145
88
  requirement: !ruby/object:Gem::Requirement
@@ -148,11 +91,6 @@ dependencies:
148
91
  - - ! '>='
149
92
  - !ruby/object:Gem::Version
150
93
  version: '1.12'
151
- prerelease:
152
- segments:
153
- - 1
154
- - 12
155
- hash: -1471803907522368170
156
94
  type: :runtime
157
95
  prerelease: false
158
96
  version_requirements: !ruby/object:Gem::Requirement
@@ -161,35 +99,22 @@ dependencies:
161
99
  - - ! '>='
162
100
  - !ruby/object:Gem::Version
163
101
  version: '1.12'
164
- prerelease:
165
- segments:
166
- - 1
167
- - 12
168
- hash: -1471803907522368170
169
102
  - !ruby/object:Gem::Dependency
170
103
  name: lockfile
171
104
  requirement: !ruby/object:Gem::Requirement
172
- none: true
105
+ none: false
173
106
  requirements:
174
107
  - - ! '>='
175
108
  - !ruby/object:Gem::Version
176
109
  version: '0'
177
- prerelease:
178
- segments:
179
- - 0
180
- hash: 780439954604562836
181
110
  type: :runtime
182
111
  prerelease: false
183
112
  version_requirements: !ruby/object:Gem::Requirement
184
- none: true
113
+ none: false
185
114
  requirements:
186
115
  - - ! '>='
187
116
  - !ruby/object:Gem::Version
188
117
  version: '0'
189
- prerelease:
190
- segments:
191
- - 0
192
- hash: 780439954604562836
193
118
  - !ruby/object:Gem::Dependency
194
119
  name: mime-types
195
120
  requirement: !ruby/object:Gem::Requirement
@@ -197,11 +122,7 @@ dependencies:
197
122
  requirements:
198
123
  - - ~>
199
124
  - !ruby/object:Gem::Version
200
- version: '1'
201
- prerelease:
202
- segments:
203
- - 1
204
- hash: -2685865212927832791
125
+ version: '1.0'
205
126
  type: :runtime
206
127
  prerelease: false
207
128
  version_requirements: !ruby/object:Gem::Requirement
@@ -209,11 +130,7 @@ dependencies:
209
130
  requirements:
210
131
  - - ~>
211
132
  - !ruby/object:Gem::Version
212
- version: '1'
213
- prerelease:
214
- segments:
215
- - 1
216
- hash: -2685865212927832791
133
+ version: '1.0'
217
134
  - !ruby/object:Gem::Dependency
218
135
  name: locale
219
136
  requirement: !ruby/object:Gem::Requirement
@@ -222,11 +139,6 @@ dependencies:
222
139
  - - ~>
223
140
  - !ruby/object:Gem::Version
224
141
  version: '2.0'
225
- prerelease:
226
- segments:
227
- - 2
228
- - 0
229
- hash: -535226096568000350
230
142
  type: :runtime
231
143
  prerelease: false
232
144
  version_requirements: !ruby/object:Gem::Requirement
@@ -235,55 +147,38 @@ dependencies:
235
147
  - - ~>
236
148
  - !ruby/object:Gem::Version
237
149
  version: '2.0'
238
- prerelease:
239
- segments:
240
- - 2
241
- - 0
242
- hash: -535226096568000350
243
150
  - !ruby/object:Gem::Dependency
244
151
  name: chronic
245
152
  requirement: !ruby/object:Gem::Requirement
246
153
  none: false
247
154
  requirements:
248
155
  - - ~>
249
- - !ruby/object:Gem::Version
250
- version: '0.9'
251
- prerelease:
252
- segments:
253
- - 0
254
- - 9
255
- hash: 2184205100294773721
256
- - - ! '>='
257
156
  - !ruby/object:Gem::Version
258
157
  version: 0.9.1
259
- prerelease:
260
- segments:
261
- - 0
262
- - 9
263
- - 1
264
- hash: -1556404584947433146
265
158
  type: :runtime
266
159
  prerelease: false
267
160
  version_requirements: !ruby/object:Gem::Requirement
268
161
  none: false
269
162
  requirements:
270
163
  - - ~>
271
- - !ruby/object:Gem::Version
272
- version: '0.9'
273
- prerelease:
274
- segments:
275
- - 0
276
- - 9
277
- hash: 2184205100294773721
278
- - - ! '>='
279
164
  - !ruby/object:Gem::Version
280
165
  version: 0.9.1
281
- prerelease:
282
- segments:
283
- - 0
284
- - 9
285
- - 1
286
- hash: -1556404584947433146
166
+ - !ruby/object:Gem::Dependency
167
+ name: unicode
168
+ requirement: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 0.4.4
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: 0.4.4
287
182
  - !ruby/object:Gem::Dependency
288
183
  name: bundler
289
184
  requirement: !ruby/object:Gem::Requirement
@@ -323,7 +218,7 @@ dependencies:
323
218
  requirements:
324
219
  - - ~>
325
220
  - !ruby/object:Gem::Version
326
- version: '4'
221
+ version: '4.7'
327
222
  type: :development
328
223
  prerelease: false
329
224
  version_requirements: !ruby/object:Gem::Requirement
@@ -331,7 +226,7 @@ dependencies:
331
226
  requirements:
332
227
  - - ~>
333
228
  - !ruby/object:Gem::Version
334
- version: '4'
229
+ version: '4.7'
335
230
  - !ruby/object:Gem::Dependency
336
231
  name: rr
337
232
  requirement: !ruby/object:Gem::Requirement
@@ -339,7 +234,7 @@ dependencies:
339
234
  requirements:
340
235
  - - ~>
341
236
  - !ruby/object:Gem::Version
342
- version: '1.0'
237
+ version: 1.0.5
343
238
  type: :development
344
239
  prerelease: false
345
240
  version_requirements: !ruby/object:Gem::Requirement
@@ -347,7 +242,23 @@ dependencies:
347
242
  requirements:
348
243
  - - ~>
349
244
  - !ruby/object:Gem::Version
350
- version: '1.0'
245
+ version: 1.0.5
246
+ - !ruby/object:Gem::Dependency
247
+ name: gpgme
248
+ requirement: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: 2.0.2
254
+ type: :development
255
+ prerelease: false
256
+ version_requirements: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ! '>='
260
+ - !ruby/object:Gem::Version
261
+ version: 2.0.2
351
262
  description: ! " Sup is a console-based email client for people with a lot of
352
263
  email.\n\n * GMail-like thread-centered archiving, tagging and muting\n *
353
264
  Handling mail from multiple mbox and Maildir sources\n * Blazing fast full-text
@@ -365,6 +276,7 @@ executables:
365
276
  - sup-sync
366
277
  - sup-sync-back
367
278
  - sup-tweak-labels
279
+ - sup-psych-ify-config-files
368
280
  extensions: []
369
281
  extra_rdoc_files: []
370
282
  files:
@@ -382,7 +294,9 @@ files:
382
294
  - bin/sup-sync
383
295
  - bin/sup-sync-back
384
296
  - bin/sup-tweak-labels
297
+ - bin/sup-psych-ify-config-files
385
298
  - lib/sup/hook.rb
299
+ - lib/sup/util/query.rb
386
300
  - lib/sup/util/uri.rb
387
301
  - lib/sup/util/path.rb
388
302
  - lib/sup/horizontal_selector.rb
@@ -448,7 +362,9 @@ files:
448
362
  homepage: http://supmua.org
449
363
  licenses:
450
364
  - GPL-2
451
- post_install_message:
365
+ post_install_message: ! "SUP: Please run `sup-psych-ify-config-files` to migrate from
366
+ 0.13 to 0.14.\n\nSUP: Check https://github.com/sup-heliotrope/sup/wiki/Migration-0.13-to-0.14\n
367
+ \ for more detailed up-to-date instructions.\n"
452
368
  rdoc_options: []
453
369
  require_paths:
454
370
  - lib
@@ -457,7 +373,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
457
373
  requirements:
458
374
  - - ! '>='
459
375
  - !ruby/object:Gem::Version
460
- version: '0'
376
+ version: 1.9.2
461
377
  required_rubygems_version: !ruby/object:Gem::Requirement
462
378
  none: false
463
379
  requirements: