jpmobile 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86c3a91d387a147b06a1e8698b4ddcbba1e62c52
4
- data.tar.gz: 51c89371e9075628a87c5cdf03cff1922da39466
3
+ metadata.gz: 154aabed283366bd8c6fba6825b99d62e96cf78c
4
+ data.tar.gz: b62fa66625f4f710930f00fa3ff20bd2997ed8a9
5
5
  SHA512:
6
- metadata.gz: 5897e0d386accbb2ba9aee29161317c44e550974cf021775badcd932ab77c58475feff381e6da9cff37f0cfb57fb7246cd224916fa0dcbc0255dee34bf430f83
7
- data.tar.gz: 78e415d4aea5194564eaaf04dd6a1c5b06cc4c862868bd644555a82433bd127dfd9f8f2c02bd7f6ef7d5f5d6ae1f3ad1118ed9ab1d75d4707c6a8cd831c95096
6
+ metadata.gz: 3fa80365078d094087533cf1b1b70d1aa84f3f0336bbf98c7e5ca6ce18d607b35d277b103ac9ea8f3782dfd44f77d17bff4ec8d1dfad2e14a3ae1d575bfaa969
7
+ data.tar.gz: 09c776d1b5e90bcaaf563dee8c2b87b6b1f275df76d31b116292d5521e84899d019fb30a1d30c2557330618ebf5daebcc2f1dad709b2e967d1bbfa168a58af50
@@ -16,12 +16,13 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
  gem.require_paths = ["lib"]
18
18
 
19
- gem.add_development_dependency 'rails'
19
+ gem.add_development_dependency 'rails', '~> 4.0.0'
20
20
  gem.add_development_dependency 'rspec'
21
21
  gem.add_development_dependency 'rspec-rails'
22
22
  gem.add_development_dependency 'webrat'
23
23
  gem.add_development_dependency 'geokit'
24
24
  gem.add_development_dependency 'sqlite3-ruby'
25
+ gem.add_development_dependency 'nokogiri', '1.6.2.1'
25
26
  gem.add_development_dependency 'hpricot'
26
27
  gem.add_development_dependency 'git'
27
28
  end
@@ -2,12 +2,10 @@
2
2
  # = 半角変換フィルター
3
3
  # thanks to masuidrive <masuidrive (at) masuidrive.jp>
4
4
 
5
- class ActionController::Base #:nodoc:
5
+ ActiveSupport.on_load(:action_controller) do
6
6
  def self.hankaku_filter(options={})
7
- options = {:input => false}.update(options)
8
-
9
- before_filter lambda {|controller| Jpmobile::HankakuFilter.before(controller, options)}
10
- after_filter lambda {|controller| Jpmobile::HankakuFilter.after(controller, options)}
7
+ before_action Jpmobile::HankakuFilter.new(options)
8
+ after_action Jpmobile::HankakuFilter.new(options)
11
9
  end
12
10
 
13
11
  def self.mobile_filter(options={})
@@ -18,43 +16,99 @@ class ActionController::Base #:nodoc:
18
16
  end
19
17
 
20
18
  module Jpmobile
21
- module HankakuFilter
22
- module_function
19
+ class HankakuFilter
20
+ cattr_accessor(:zen_to_han_table) do
21
+ {
22
+ "ガ" => "ガ", "ギ" => "ギ", "グ" => "グ", "ゲ" => "ゲ", "ゴ" => "ゴ",
23
+ "ザ" => "ザ", "ジ" => "ジ", "ズ" => "ズ", "ゼ" => "ゼ", "ゾ" => "ゾ",
24
+ "ダ" => "ダ", "ヂ" => "ヂ", "ヅ" => "ヅ", "デ" => "デ", "ド" => "ド",
25
+ "バ" => "バ", "ビ" => "ビ", "ブ" => "ブ", "ベ" => "ベ", "ボ" => "ボ",
26
+ "パ" => "パ", "ピ" => "ピ", "プ" => "プ", "ペ" => "ペ", "ポ" => "ポ",
27
+ "ヴ" => "ヴ",
28
+ "ア" => "ア", "イ" => "イ", "ウ" => "ウ", "エ" => "エ", "オ" => "オ",
29
+ "カ" => "カ", "キ" => "キ", "ク" => "ク", "ケ" => "ケ", "コ" => "コ",
30
+ "サ" => "サ", "シ" => "シ", "ス" => "ス", "セ" => "セ", "ソ" => "ソ",
31
+ "タ" => "タ", "チ" => "チ", "ツ" => "ツ", "テ" => "テ", "ト" => "ト",
32
+ "ナ" => "ナ", "ニ" => "ニ", "ヌ" => "ヌ", "ネ" => "ネ", "ノ" => "ノ",
33
+ "ハ" => "ハ", "ヒ" => "ヒ", "フ" => "フ", "ヘ" => "ヘ", "ホ" => "ホ",
34
+ "マ" => "マ", "ミ" => "ミ", "ム" => "ム", "メ" => "メ", "モ" => "モ",
35
+ "ヤ" => "ヤ", "ユ" => "ユ", "ヨ" => "ヨ",
36
+ "ラ" => "ラ", "リ" => "リ", "ル" => "ル", "レ" => "レ", "ロ" => "ロ",
37
+ "ワ" => "ワ", "ヲ" => "ヲ", "ン" => "ン",
38
+ "ャ" => "ャ", "ュ" => "ュ", "ョ" => "ョ",
39
+ "ァ" => "ァ", "ィ" => "ィ", "ゥ" => "ゥ", "ェ" => "ェ", "ォ" => "ォ",
40
+ "ッ" => "ッ",
41
+ "゛" => "゙", "゜" => "゚", "ー" => "ー", "。" => "。",
42
+ "「" => "「", "」" => "」",
43
+ "、" => "、", "・" => "・", "!" => "!", "?" => "?",
44
+ }
45
+ end
23
46
 
24
- # 入出力フィルタの適用条件
25
- def apply_incoming?(controller)
26
- controller.request.mobile?
47
+ class << self
48
+ def hankaku_format(str)
49
+ replace_chars(str, zen_to_han_table)
50
+ end
51
+
52
+ def zenkaku_format(str)
53
+ replace_chars(str, han_to_zen_table)
54
+ end
55
+
56
+ private
57
+
58
+ def replace_chars(str, table)
59
+ @regexp_cache ||= {}
60
+ str.gsub(@regexp_cache[table.object_id] ||= Regexp.union(table.keys), table)
61
+ end
62
+
63
+ def han_to_zen_table
64
+ @han_to_zen_table ||= zen_to_han_table.invert
65
+ end
27
66
  end
28
- def apply_outgoing?(controller)
29
- controller.request.mobile? and
30
- [nil, "text/html", "application/xhtml+xml"].include?(controller.response.content_type)
67
+
68
+ def initialize(options = {})
69
+ @options = {
70
+ :input => false,
71
+ }.merge(options)
72
+
73
+ @controller = nil
31
74
  end
32
75
 
33
- def before(controller, options = {})
34
- if apply_incoming?(controller)
35
- Util.deep_apply(controller.params) do |value|
36
- value = to_internal(value, options)
76
+ def before(controller)
77
+ @controller = controller
78
+ if apply_incoming?
79
+ Util.deep_apply(@controller.params) do |value|
80
+ value = to_internal(value)
37
81
  end
38
82
  end
39
83
  end
84
+
40
85
  # 内部コードから外部コードに変換
41
- def after(controller, options = {})
42
- if apply_outgoing?(controller) and controller.response.body.is_a?(String)
43
- if controller.request.mobile?
44
- options.merge!(:charset => controller.request.mobile.default_charset)
45
- end
46
- controller.response.body = to_external(controller.response.body, options)
86
+ def after(controller)
87
+ @controller = controller
88
+ if apply_outgoing? and @controller.response.body.is_a?(String)
89
+ @controller.response.body = to_external(@controller.response.body)
47
90
  end
48
91
  end
49
92
 
50
- @@internal = %w(ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ ヴ ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン ャ ュ ョ ァ ィ ゥ ェ ォ ッ ゛ ゜ ー 。 「 」 、 ・ ! ?).freeze
51
- @@external = %w(ガ ギ グ ゲ ゴ ザ ジ ズ ゼ ゾ ダ ヂ ヅ デ ド バ ビ ブ ベ ボ パ ピ プ ペ ポ ヴ ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ヲ ン ャ ュ ョ ァ ィ ゥ ェ ォ ッ ゙ ゚ ー 。 「 」 、 ・ ! ?).freeze
52
- def to_internal(str, options = {})
53
- filter(str, @@external, @@internal)
93
+ private
94
+
95
+ # 入出力フィルタの適用条件
96
+ def apply_incoming?
97
+ @controller.request.mobile?
54
98
  end
55
- def to_external(str, options = {})
56
- unless options[:input]
57
- filter(str, @@internal, @@external)
99
+
100
+ def apply_outgoing?
101
+ @controller.request.mobile? and
102
+ [nil, "text/html", "application/xhtml+xml"].include?(@controller.response.content_type)
103
+ end
104
+
105
+ def to_internal(str)
106
+ filter(:zenkaku, str)
107
+ end
108
+
109
+ def to_external(str)
110
+ unless @options[:input]
111
+ filter(:hankaku, str)
58
112
  else
59
113
  encoding = (str =~ /^\s*<[^Hh>]*html/) and str.respond_to?(:encoding)
60
114
  nokogiri_klass =
@@ -68,12 +122,12 @@ module Jpmobile
68
122
  doc = convert_text_content(doc)
69
123
 
70
124
  html = doc.to_html.gsub("\xc2\xa0","&nbsp;")
71
- html = html.gsub(/charset=[a-z0-9\-]+/i, "charset=#{options[:charset]}") if options[:charset]
125
+ html = html.gsub(/charset=[a-z0-9\-]+/i, "charset=#{default_charset}") if default_charset
72
126
  html
73
127
  end
74
128
  end
75
129
 
76
- def filter(str, from, to)
130
+ def filter(method, str)
77
131
  str = str.clone
78
132
 
79
133
  # 一度UTF-8に変換
@@ -83,9 +137,7 @@ module Jpmobile
83
137
  str.force_encoding("UTF-8")
84
138
  end
85
139
 
86
- from.each_with_index do |int, i|
87
- str.gsub!(int, to[i])
88
- end
140
+ str = self.class.send("#{method}_format", str)
89
141
 
90
142
  # 元に戻す
91
143
  if before_encoding
@@ -101,11 +153,11 @@ module Jpmobile
101
153
  if element.kind_of?(Nokogiri::XML::Text)
102
154
  unless element.parent.node_name == "textarea"
103
155
  # textarea 以外のテキストなら content を変換
104
- element.content = filter(element.content, @@internal, @@external)
156
+ element.content = filter(:hankaku, element.content)
105
157
  end
106
158
  elsif element.node_name == "input" and ["submit", "reset", "button"].include?(element["type"])
107
159
  # テキスト以外でもボタンの value は変換
108
- element["value"] = filter(element["value"], @@internal, @@external)
160
+ element["value"] = filter(:hankaku, element["value"])
109
161
  elsif element.children.any?
110
162
  # 子要素があれば再帰的に変換
111
163
  element = convert_text_content(element)
@@ -114,5 +166,11 @@ module Jpmobile
114
166
 
115
167
  document
116
168
  end
169
+
170
+ def default_charset
171
+ if @controller.request.mobile?
172
+ @controller.request.mobile.default_charset
173
+ end
174
+ end
117
175
  end
118
176
  end
@@ -29,12 +29,6 @@ module Mail
29
29
  def mobile=(m)
30
30
  if @mobile = m
31
31
  @charset = m.mail_charset(@charset)
32
-
33
- if self.body
34
- self.body.content_type_with_jpmobile = self.content_type
35
- self.body.charset = @charset
36
- self.body.mobile = m
37
- end
38
32
  end
39
33
  end
40
34
 
@@ -47,7 +41,6 @@ module Mail
47
41
 
48
42
  ready_to_send!
49
43
 
50
- self.body.charset = @charset
51
44
  self.body.mobile = @mobile
52
45
  self.header['Content-Transfer-Encoding'].value = @mobile.content_transfer_encoding(self.header)
53
46
  if @mobile.decorated?
@@ -84,6 +77,18 @@ module Mail
84
77
  self.body = body_part
85
78
  end
86
79
 
80
+ def init_with_hash_with_jpmobile(hash)
81
+ if hash[:body_raw]
82
+ @mobile = hash[:mobile]
83
+ init_with_string(hash[:body_raw])
84
+ else
85
+ init_with_hash_without_jpmobile(hash)
86
+ end
87
+ end
88
+
89
+ alias_method :init_with_hash_without_jpmobile, :init_with_hash
90
+ alias_method :init_with_hash, :init_with_hash_with_jpmobile
91
+
87
92
  def init_with_string(string)
88
93
  # convert to ASCII-8BIT for ascii incompatible encodings
89
94
  s = Jpmobile::Util.ascii_8bit(string)
@@ -97,7 +102,6 @@ module Mail
97
102
  process_body_raw_without_jpmobile
98
103
 
99
104
  if @mobile
100
- @body.charset = @charset
101
105
  @body.mobile = @mobile
102
106
  @body.content_type_with_jpmobile = self.content_type
103
107
 
@@ -121,6 +125,11 @@ module Mail
121
125
  @raw_source = value.to_crlf
122
126
  end
123
127
 
128
+ def separate_parts_with_jpmobile
129
+ @body.mobile = @mobile
130
+ separate_parts_without_jpmobile
131
+ end
132
+
124
133
  alias_method :encoded_without_jpmobile, :encoded
125
134
  alias_method :encoded, :encoded_with_jpmobile
126
135
 
@@ -130,6 +139,9 @@ module Mail
130
139
  alias_method :process_body_raw_without_jpmobile, :process_body_raw
131
140
  alias_method :process_body_raw, :process_body_raw_with_jpmobile
132
141
 
142
+ alias_method :separate_parts_without_jpmobile, :separate_parts
143
+ alias_method :separate_parts, :separate_parts_with_jpmobile
144
+
133
145
  # -- docomo
134
146
  # multipart/mixed
135
147
  # |- multipart/related
@@ -230,34 +242,23 @@ module Mail
230
242
  # override charset
231
243
  if self.header[:content_type]
232
244
  content_type_charset = Jpmobile::Util.extract_charset(self.header[:content_type].value)
245
+ @charset = content_type_charset
233
246
  unless content_type_charset.blank?
234
- @charset = content_type_charset
235
247
  self.header[:content_type].parameters[:charset] = @charset
236
248
  @mobile_main_type = self.header[:content_type].main_type
237
249
  end
238
-
239
- if !Jpmobile::Email.convertable?(self.header[:content_type].value) and content_type_charset.blank?
240
- @charset = ''
241
- end
242
250
  end
243
251
 
244
252
  # convert header(s)
245
253
  if self.header[:subject]
246
254
  subject_charset = Jpmobile::Util.extract_charset(self.header[:subject].value)
247
-
248
- # override subject encoding if @charset is blank
249
- @charset = subject_charset if !subject_charset.blank? # and @charset.blank?
250
255
  self.header[:subject].charset = subject_charset unless subject_charset.blank?
251
256
 
252
257
  if @mobile
253
258
  subject_value = Encodings.value_decode(self.header[:subject].value)
254
259
  subject_converting_encoding = Jpmobile::Util.detect_encoding(subject_value)
255
260
  v = @mobile.to_mail_internal(subject_value, subject_converting_encoding)
256
- if @charset == subject_charset and @mobile.mail_charset != @charset
257
- self.header[:subject].value = Jpmobile::Util.force_encode(v, @charset, Jpmobile::Util::UTF8)
258
- else
259
- self.header[:subject].value = Jpmobile::Util.force_encode(v, @mobile.mail_charset(@charset), Jpmobile::Util::UTF8)
260
- end
261
+ self.header[:subject].value = Jpmobile::Util.force_encode(v, @mobile.mail_charset(subject_charset), Jpmobile::Util::UTF8)
261
262
  end
262
263
  end
263
264
 
@@ -322,25 +323,18 @@ module Mail
322
323
  # convert encoding
323
324
  def encoded_with_jpmobile(transfer_encoding = '8bit')
324
325
  if @mobile and !multipart?
325
- if @mobile.to_mail_body_encoded?(@raw_source)
326
- @raw_source
327
- elsif Jpmobile::Util.ascii_8bit?(@raw_source)
326
+ case transfer_encoding
327
+ when /base64/
328
328
  _raw_source = if transfer_encoding == encoding
329
- @raw_source
329
+ @raw_source.dup
330
330
  else
331
- enc = Mail::Encodings::get_encoding(get_best_encoding(transfer_encoding))
332
- enc.encode(@raw_source)
331
+ get_best_encoding(transfer_encoding).encode(@raw_source)
333
332
  end
334
- Jpmobile::Util.force_encode(_raw_source, nil, @charset)
333
+ Jpmobile::Util.set_encoding(_raw_source, @mobile.mail_charset(@charset))
334
+ when /quoted-printable/
335
+ Jpmobile::Util.set_encoding([@mobile.to_mail_body(@raw_source)].pack("M").gsub(/\n/, "\r\n"), @mobile.mail_charset(@charset))
335
336
  else
336
- case transfer_encoding
337
- when /quoted-printable/
338
- # [str].pack("M").gsub(/\n/, "\r\n")
339
- Jpmobile::Util.force_encode([@mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, @charset, Jpmobile::Util::UTF8))].pack("M").gsub(/\n/, "\r\n"), Jpmobile::Util::BINARY, @charset)
340
- # @mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, @charset, Jpmobile::Util::UTF8))
341
- else
342
- @mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, @charset, Jpmobile::Util::UTF8))
343
- end
337
+ @mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, nil, Jpmobile::Util::UTF8))
344
338
  end
345
339
  else
346
340
  encoded_without_jpmobile(transfer_encoding)
@@ -366,9 +360,7 @@ module Mail
366
360
 
367
361
  if self.multipart? and @mobile
368
362
  self.parts.each do |part|
369
- part.charset = @mobile.mail_charset(part.charset)
370
363
  part.mobile = @mobile
371
- part.body.charset = part.charset
372
364
  part.body.mobile = @mobile
373
365
  end
374
366
  end
@@ -382,7 +374,7 @@ module Mail
382
374
 
383
375
  def preamble_with_jpmobile
384
376
  if @mobile
385
- Jpmobile::Util.encode(@preamble, @charset)
377
+ Jpmobile::Util.encode(@preamble, @mobile.mail_charset(@charset))
386
378
  else
387
379
  preamble_without_jpmobile
388
380
  end
@@ -390,7 +382,7 @@ module Mail
390
382
 
391
383
  def epilogue_with_jpmobile
392
384
  if @mobile
393
- Jpmobile::Util.encode(@epilogue, @charset)
385
+ Jpmobile::Util.encode(@epilogue, @mobile.mail_charset(@charset))
394
386
  else
395
387
  epilogue_without_jpmobile
396
388
  end
@@ -398,7 +390,7 @@ module Mail
398
390
 
399
391
  def crlf_boundary_with_jpmobile
400
392
  if @mobile
401
- Jpmobile::Util.encode(crlf_boundary_without_jpmobile, @charset)
393
+ Jpmobile::Util.encode(crlf_boundary_without_jpmobile, @mobile.mail_charset(@charset))
402
394
  else
403
395
  crlf_boundary_without_jpmobile
404
396
  end
@@ -406,7 +398,7 @@ module Mail
406
398
 
407
399
  def end_boundary_with_jpmobile
408
400
  if @mobile
409
- Jpmobile::Util.encode(end_boundary_without_jpmobile, @charset)
401
+ Jpmobile::Util.encode(end_boundary_without_jpmobile, @mobile.mail_charset(@charset))
410
402
  else
411
403
  end_boundary_without_jpmobile
412
404
  end
@@ -435,6 +427,17 @@ module Mail
435
427
 
436
428
  alias_method :epilogue_without_jpmobile, :epilogue
437
429
  alias_method :epilogue, :epilogue_with_jpmobile
430
+
431
+ def split!(boundary)
432
+ self.boundary = boundary
433
+ parts = raw_source.split(/(?:\A|\r\n)--#{Regexp.escape(boundary)}(?=(?:--)?\s*$)/)
434
+ # Make the preamble equal to the preamble (if any)
435
+ self.preamble = parts[0].to_s.strip
436
+ # Make the epilogue equal to the epilogue (if any)
437
+ self.epilogue = parts[-1].to_s.sub('--', '').strip
438
+ parts[1...-1].to_a.each { |part| @parts << Mail::Part.new(:body_raw => part, :mobile => @mobile) }
439
+ self
440
+ end
438
441
  end
439
442
 
440
443
  class UnstructuredField
@@ -28,7 +28,6 @@ module Jpmobile
28
28
  m = super(headers, &block)
29
29
 
30
30
  m.mobile = @mobile
31
- m.charset = @mobile.mail_charset
32
31
 
33
32
  # for decorated-mail manipulation
34
33
  m.rearrange! if @mobile.decorated?
@@ -130,8 +130,10 @@ module Jpmobile::TransSid #:nodoc:
130
130
  key
131
131
  end
132
132
  # session_idを返す
133
+ # rack 1.4 (rails3) request.session_options[:id]
134
+ # rack 1.5 (rails4) request.session.id
133
135
  def jpmobile_session_id
134
- request.session_options[:id] rescue session.session_id
136
+ request.session_options[:id] || request.session.id
135
137
  end
136
138
  # session_idを埋め込むためのhidden fieldを出力する。
137
139
  def sid_hidden_field_tag
@@ -1,3 +1,3 @@
1
1
  module Jpmobile
2
- VERSION = "4.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
@@ -0,0 +1,45 @@
1
+ X-Account-Key: account2
2
+ X-UIDL: UID44724-1271041990
3
+ X-Mozilla-Status: 0001
4
+ X-Mozilla-Status2: 10000000
5
+ X-Mozilla-Keys:
6
+ Return-Path: <info@jp.mobile>
7
+ X-Original-To: info+to@jp.mobile
8
+ Delivered-To: info+to@jp.mobile
9
+ Received: from localhost (localhost [127.0.0.1])
10
+ by mx1.jp.mobile (Postfix) with ESMTP id 916D982D3C
11
+ for <info+to@jp.mobile>; Mon, 17 Jan 2011 16:43:00 +0900 (JST)
12
+ Received: from mx1.jp.mobile ([127.0.0.1])
13
+ by localhost (mx1.jp.mobile [127.0.0.1]) (amavisd-new, port 10024)
14
+ with ESMTP id 4c+D+lqN6aOJ for <info+to@jp.mobile>;
15
+ Mon, 17 Jan 2011 16:43:00 +0900 (JST)
16
+ Received: by mx1.jp.mobile (Postfix, from userid 58)
17
+ id 68BFD82D33; Mon, 17 Jan 2011 16:43:00 +0900 (JST)
18
+ Message-ID: <4D33F300.8050702@jpmobile.jp>
19
+ Date: Mon, 17 Jan 2011 16:42:56 +0900
20
+ From: Shin-ichiro OGAWA <info@jpmobile.jp>
21
+ User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100329)
22
+ MIME-Version: 1.0
23
+ To: info+to@jp.mobile
24
+ Subject:
25
+ Content-Type: multipart/mixed;
26
+ boundary="------------010605060509040104050402"
27
+
28
+ This is a multi-part message in MIME format.
29
+ --------------010605060509040104050402
30
+ Content-Type: text/plain; charset=ISO-2022-JP
31
+ Content-Transfer-Encoding: 7bit
32
+
33
+ $BK\J8$G$9(B
34
+
35
+
36
+ --------------010605060509040104050402
37
+ Content-Transfer-Encoding: base64
38
+ Content-Type: image/gif;
39
+ name="Transparent.gif"
40
+ Content-Disposition: attachment;
41
+ filename="Transparent.gif"
42
+
43
+ R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
44
+ --------------010605060509040104050402--
45
+
@@ -67,6 +67,21 @@ describe "Jpmobile::Mail#receive" do
67
67
  end
68
68
  end
69
69
 
70
+ describe "PC mail without subject" do
71
+ before(:each) do
72
+ @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/pc-mail-attached-without-subject.eml")).read)
73
+ end
74
+
75
+ it "body should be parsed correctly" do
76
+ @mail.body.parts.size.should == 2
77
+ @mail.body.parts.first.body.to_s.should == "本文です\n\n"
78
+ end
79
+
80
+ it "should encode correctly" do
81
+ ascii_8bit(@mail.to_s).should match(/GODlhAQABAIAAAAAAAP/)
82
+ end
83
+ end
84
+
70
85
  describe "Docomo" do
71
86
  before(:each) do
72
87
  @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "../../test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml")).read)
@@ -258,7 +273,7 @@ describe "Jpmobile::Mail#receive" do
258
273
 
259
274
  it 'should be encoded correctly' do
260
275
  @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-message.eml")).read)
261
- @mail.encoded
276
+ @mail.encoded.should match(Regexp.escape("%[\e$B1`;yL>\e(B]%\e$B$N\e(B%[\e$BJ]8n<TL>\e(B]%"))
262
277
  end
263
278
  end
264
279
 
@@ -271,14 +286,14 @@ describe "Jpmobile::Mail#receive" do
271
286
 
272
287
  it 'should be encoded correctly' do
273
288
  @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/iphone-mail3.eml")).read)
274
- @mail.encoded
289
+ @mail.encoded.should match(/BK\\J82~9T\$J\$7!2#5#1#2J8;z!2/)
275
290
  end
276
291
  end
277
292
 
278
293
  it 'should not raise when parsing attached email' do
279
294
  lambda {
280
295
  @mail = Mail.new(open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/au-attached.eml")).read)
281
- @mail.encoded
296
+ @mail.encoded.should match('/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPQAA')
282
297
  }.should_not raise_error
283
298
  end
284
299
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jpmobile
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shin-ichiro OGAWA
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-26 00:00:00.000000000 Z
12
+ date: 2014-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: 4.0.0
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: 4.0.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +95,20 @@ dependencies:
95
95
  - - '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: nokogiri
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '='
103
+ - !ruby/object:Gem::Version
104
+ version: 1.6.2.1
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '='
110
+ - !ruby/object:Gem::Version
111
+ version: 1.6.2.1
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: hpricot
100
114
  requirement: !ruby/object:Gem::Requirement
@@ -228,6 +242,7 @@ files:
228
242
  - spec/unit/email-fixtures/docomo-jis.eml
229
243
  - spec/unit/email-fixtures/iphone-mail3.eml
230
244
  - spec/unit/email-fixtures/iphone-message.eml
245
+ - spec/unit/email-fixtures/pc-mail-attached-without-subject.eml
231
246
  - spec/unit/email-fixtures/pc-mail-multi.eml
232
247
  - spec/unit/email-fixtures/pc-mail-single.eml
233
248
  - spec/unit/email-fixtures/photo.jpg
@@ -400,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
400
415
  version: '0'
401
416
  requirements: []
402
417
  rubyforge_project:
403
- rubygems_version: 2.0.2
418
+ rubygems_version: 2.0.14
404
419
  signing_key:
405
420
  specification_version: 4
406
421
  summary: A Rails plugin for mobile devices in Japan
@@ -434,6 +449,7 @@ test_files:
434
449
  - spec/unit/email-fixtures/docomo-jis.eml
435
450
  - spec/unit/email-fixtures/iphone-mail3.eml
436
451
  - spec/unit/email-fixtures/iphone-message.eml
452
+ - spec/unit/email-fixtures/pc-mail-attached-without-subject.eml
437
453
  - spec/unit/email-fixtures/pc-mail-multi.eml
438
454
  - spec/unit/email-fixtures/pc-mail-single.eml
439
455
  - spec/unit/email-fixtures/photo.jpg