jpmobile 5.2.4 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.onkcop-config.yml +396 -0
- data/.rubocop.yml +71 -10
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +157 -129
- data/README.md +2 -2
- data/jpmobile.gemspec +5 -1
- data/lib/jpmobile.rb +1 -0
- data/lib/jpmobile/configuration.rb +7 -3
- data/lib/jpmobile/docomo_guid.rb +2 -2
- data/lib/jpmobile/email.rb +2 -4
- data/lib/jpmobile/emoticon.rb +16 -23
- data/lib/jpmobile/filter.rb +9 -4
- data/lib/jpmobile/hook_action_view.rb +4 -10
- data/lib/jpmobile/hook_test_request.rb +1 -1
- data/lib/jpmobile/mail.rb +7 -7
- data/lib/jpmobile/mailer.rb +1 -1
- data/lib/jpmobile/mobile/abstract_mobile.rb +1 -1
- data/lib/jpmobile/mobile/android.rb +1 -1
- data/lib/jpmobile/mobile/au.rb +2 -2
- data/lib/jpmobile/mobile/black_berry.rb +1 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -1
- data/lib/jpmobile/mobile/docomo.rb +6 -8
- data/lib/jpmobile/mobile/emobile.rb +2 -2
- data/lib/jpmobile/mobile/ipad.rb +1 -1
- data/lib/jpmobile/mobile/iphone.rb +1 -1
- data/lib/jpmobile/mobile/softbank.rb +2 -2
- data/lib/jpmobile/mobile/vodafone.rb +2 -2
- data/lib/jpmobile/mobile/willcom.rb +2 -2
- data/lib/jpmobile/mobile/windows_phone.rb +1 -1
- data/lib/jpmobile/rack/params_filter.rb +5 -4
- data/lib/jpmobile/rails.rb +9 -41
- data/lib/jpmobile/resolver.rb +4 -37
- data/lib/jpmobile/session/active_record_store.rb +1 -1
- data/lib/jpmobile/session/mem_cache_store.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +1 -1
- data/lib/jpmobile/util.rb +4 -5
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +4 -4
- data/spec/rack/jpmobile/emoticon_spec.rb +48 -48
- data/spec/rack_helper.rb +1 -5
- data/spec/unit/email_spec.rb +1 -1
- data/spec/unit/receive_mail_spec.rb +10 -10
- data/spec/unit/util_spec.rb +4 -4
- data/test/rails/overrides/Gemfile.jpmobile +1 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/mailboxes/application_mailbox.rb +3 -0
- data/test/rails/overrides/app/mailboxes/mobile_mailer_mailbox.rb +5 -0
- data/test/rails/overrides/app/mailers/decorated_mailer.rb +1 -1
- data/test/rails/overrides/db/migrate/20201111033056_create_active_storage_tables.active_storage.rb +36 -0
- data/test/rails/overrides/db/migrate/20201111033057_create_action_mailbox_tables.action_mailbox.rb +14 -0
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +2 -2
- data/test/rails/overrides/spec/controllers/hankaku_filter_controller_spec.rb +1 -1
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +2 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-attached.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-decomail.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji2.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/au-emoji5.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/bounced-jp.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-emoji.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-gmail-sjis.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/docomo-jis.eml +0 -0
- data/{spec/unit/email-fixtures → test/rails/overrides/spec/fixtures/files/mobile_mailer}/iphone-message.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/no-from.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/non-jp.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/photo.jpg +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-blank.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-emoji-utf8.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-emoji.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-gmail-sjis.eml +0 -0
- data/test/rails/overrides/spec/fixtures/{mobile_mailer → files/mobile_mailer}/softbank-gmail-utf8.eml +0 -0
- data/test/rails/overrides/spec/mailboxes/mobile_mailer_mailbox_spec.rb +265 -0
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +0 -305
- data/test/rails/overrides/spec/requests/emobile_spec.rb +2 -2
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +9 -9
- metadata +81 -43
data/lib/jpmobile/email.rb
CHANGED
@@ -20,7 +20,7 @@ module Jpmobile
|
|
20
20
|
Mobile.carriers.each do |const|
|
21
21
|
c = Mobile.const_get(const)
|
22
22
|
if c::MAIL_ADDRESS_REGEXP &&
|
23
|
-
header.match(/(\S+@[A-Za-z0-9
|
23
|
+
header.match(/(\S+@[A-Za-z0-9\-._]+)/) &&
|
24
24
|
Regexp.last_match(1).match(/^#{c::MAIL_ADDRESS_REGEXP}$/)
|
25
25
|
return c
|
26
26
|
end
|
@@ -33,14 +33,12 @@ module Jpmobile
|
|
33
33
|
nil
|
34
34
|
end
|
35
35
|
|
36
|
-
attr_writer :japanese_mail_address_regexp
|
36
|
+
attr_writer :japanese_mail_address_regexp, :converting_content_type
|
37
37
|
|
38
38
|
def japanese_mail?(header)
|
39
39
|
@japanese_mail_address_regexp and header.match(@japanese_mail_address_regexp)
|
40
40
|
end
|
41
41
|
|
42
|
-
attr_writer :converting_content_type
|
43
|
-
|
44
42
|
def converting_content_type
|
45
43
|
@converting_content_type ||= ['text/plain', 'text/html']
|
46
44
|
end
|
data/lib/jpmobile/emoticon.rb
CHANGED
@@ -41,7 +41,7 @@ module Jpmobile
|
|
41
41
|
# +str+ のなかでDoCoMo絵文字をUnicode数値文字参照に置換した文字列を返す。
|
42
42
|
def self.external_to_unicodecr_docomo(str)
|
43
43
|
str.gsub(DOCOMO_SJIS_REGEXP) do |match|
|
44
|
-
sjis = match.
|
44
|
+
sjis = match.unpack1('n')
|
45
45
|
unicode = DOCOMO_SJIS_TO_UNICODE[sjis]
|
46
46
|
unicode ? ('&#x%04x;' % unicode) : match
|
47
47
|
end
|
@@ -50,7 +50,7 @@ module Jpmobile
|
|
50
50
|
# +str+ のなかでau絵文字をUnicode数値文字参照に置換した文字列を返す。
|
51
51
|
def self.external_to_unicodecr_au(str)
|
52
52
|
str.gsub(AU_SJIS_REGEXP) do |match|
|
53
|
-
sjis = match.
|
53
|
+
sjis = match.unpack1('n')
|
54
54
|
unicode = AU_SJIS_TO_UNICODE[sjis]
|
55
55
|
unicode ? ('&#x%04x;' % unicode) : match
|
56
56
|
end
|
@@ -61,7 +61,7 @@ module Jpmobile
|
|
61
61
|
str = Jpmobile::Util.ascii_8bit(in_str)
|
62
62
|
str.gsub(Jpmobile::Util.jis_string_regexp) do |jis_string|
|
63
63
|
jis_string.gsub(/[\x21-\x7e]{2}/) do |match|
|
64
|
-
jis = match.
|
64
|
+
jis = match.unpack1('n')
|
65
65
|
unicode = AU_EMAILJIS_TO_UNICODE[jis]
|
66
66
|
unicode ? Jpmobile::Util.ascii_8bit("\x1b\x28\x42&#x%04x;\x1b\x24\x42" % unicode) : match
|
67
67
|
end
|
@@ -72,7 +72,7 @@ module Jpmobile
|
|
72
72
|
def self.external_to_unicodecr_softbank(str)
|
73
73
|
# SoftBank Unicode
|
74
74
|
str.gsub(SOFTBANK_UNICODE_REGEXP) do |match|
|
75
|
-
unicode = match.
|
75
|
+
unicode = match.unpack1('U')
|
76
76
|
'&#x%04x;' % (unicode + 0x1000)
|
77
77
|
end
|
78
78
|
end
|
@@ -80,7 +80,7 @@ module Jpmobile
|
|
80
80
|
def self.external_to_unicodecr_softbank_sjis(str)
|
81
81
|
# SoftBank Shift_JIS
|
82
82
|
str.gsub(SOFTBANK_SJIS_REGEXP) do |match|
|
83
|
-
sjis = match.
|
83
|
+
sjis = match.unpack1('n')
|
84
84
|
unicode = SOFTBANK_SJIS_TO_UNICODE[sjis]
|
85
85
|
'&#x%04x;' % (unicode + 0x1000)
|
86
86
|
end
|
@@ -96,20 +96,15 @@ module Jpmobile
|
|
96
96
|
unicodes = match.unpack('U*')
|
97
97
|
unicodes = unicodes.first if unicodes.size == 1
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
when GETA_CODE
|
104
|
-
GETA
|
105
|
-
when Integer
|
106
|
-
'&#x%04x;' % emoticon
|
107
|
-
when String
|
108
|
-
emoticon
|
109
|
-
end
|
110
|
-
else
|
111
|
-
# 変換できなければ〓に
|
99
|
+
emoticon = UNICODE_EMOTICON_TO_CARRIER_EMOTICON[unicodes]
|
100
|
+
case emoticon
|
101
|
+
when GETA_CODE, nil
|
102
|
+
# 〓が指定されているか変換できなければ〓に
|
112
103
|
GETA
|
104
|
+
when Integer
|
105
|
+
'&#x%04x;' % emoticon
|
106
|
+
when String
|
107
|
+
emoticon
|
113
108
|
end
|
114
109
|
end
|
115
110
|
end
|
@@ -122,15 +117,13 @@ module Jpmobile
|
|
122
117
|
|
123
118
|
emoticon = GOOGLE_EMOTICON_TO_CARRIER_EMOTICON[unicodes]
|
124
119
|
case emoticon
|
125
|
-
when GETA_CODE
|
120
|
+
when GETA_CODE, nil
|
121
|
+
# 〓が指定されているか変換できなければ〓に
|
126
122
|
GETA
|
127
123
|
when Integer
|
128
124
|
'&#x%04x;' % emoticon
|
129
125
|
when String
|
130
126
|
emoticon
|
131
|
-
else
|
132
|
-
# 変換できなければ〓に
|
133
|
-
GETA
|
134
127
|
end
|
135
128
|
end
|
136
129
|
end
|
@@ -209,7 +202,7 @@ module Jpmobile
|
|
209
202
|
# +str+ のなかでUTF-8で表記された絵文字をUnicode数値文字参照に置換する。
|
210
203
|
def self.utf8_to_unicodecr(str)
|
211
204
|
str.gsub(UTF8_REGEXP) do |match|
|
212
|
-
'&#x%04x;' % match.
|
205
|
+
'&#x%04x;' % match.unpack1('U')
|
213
206
|
end
|
214
207
|
end
|
215
208
|
|
data/lib/jpmobile/filter.rb
CHANGED
@@ -37,6 +37,11 @@ module Jpmobile
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
+
ALLOWED_CONTENT_TYPE_REGEXP = Regexp.union(
|
41
|
+
Regexp.escape('text/html'),
|
42
|
+
Regexp.escape('application/xhtml+xm'),
|
43
|
+
)
|
44
|
+
|
40
45
|
class << self
|
41
46
|
def hankaku_format(str)
|
42
47
|
replace_chars(str, zen_to_han_table)
|
@@ -49,8 +54,8 @@ module Jpmobile
|
|
49
54
|
private
|
50
55
|
|
51
56
|
def replace_chars(str, table)
|
52
|
-
@regexp_cache ||= {}
|
53
|
-
str.gsub(@regexp_cache[table
|
57
|
+
@regexp_cache ||= {}.compare_by_identity
|
58
|
+
str.gsub(@regexp_cache[table] ||= Regexp.union(table.keys), table)
|
54
59
|
end
|
55
60
|
|
56
61
|
def han_to_zen_table
|
@@ -90,8 +95,8 @@ module Jpmobile
|
|
90
95
|
end
|
91
96
|
|
92
97
|
def apply_outgoing?
|
93
|
-
@controller.request.mobile?
|
94
|
-
|
98
|
+
@controller.request.mobile? &&
|
99
|
+
@controller.response.content_type&.match?(ALLOWED_CONTENT_TYPE_REGEXP)
|
95
100
|
end
|
96
101
|
|
97
102
|
def to_internal(str)
|
@@ -11,18 +11,12 @@ end
|
|
11
11
|
# :stopdoc:
|
12
12
|
# accept-charset に charset を変更できるようにする
|
13
13
|
module Jpmobile
|
14
|
-
module
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def html_options_for_form(url_for_options, options, *parameters_for_url)
|
19
|
-
super.tap do |o|
|
20
|
-
o['accept-charset'] = (Rails.application.config.jpmobile.form_accept_charset_conversion && request && request.mobile && request.mobile.default_charset) || o['accept-charset']
|
21
|
-
end
|
14
|
+
module HtmlOptionsWithAcceptCharset
|
15
|
+
def html_options_for_form(url_for_options, options)
|
16
|
+
super.tap do |o|
|
17
|
+
o['accept-charset'] = (Rails.application.config.jpmobile.form_accept_charset_conversion && request && request.mobile && request.mobile.default_charset) || o['accept-charset']
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
26
|
-
|
27
|
-
::ActionView::Helpers::FormTagHelper.send :prepend, Jpmobile::ActionView::HtmlOptionsWithAcceptCharset
|
28
22
|
#:startdoc:
|
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'action_controller/test_case'
|
2
|
-
ActionController::TestRequest.
|
2
|
+
ActionController::TestRequest.include Jpmobile::RequestWithMobileTesting
|
data/lib/jpmobile/mail.rb
CHANGED
@@ -173,7 +173,7 @@ module Mail
|
|
173
173
|
text_body_part = find_part_by_content_type('text/plain').first
|
174
174
|
html_body_part = find_part_by_content_type('text/html').first
|
175
175
|
html_body_part.transport_encoding = 'quoted-printable' if html_body_part
|
176
|
-
inline_images
|
176
|
+
inline_images = []
|
177
177
|
attached_files = []
|
178
178
|
attachments.each do |p|
|
179
179
|
if p.content_type.match(%r{^image/}) && p.content_disposition.match(/^inline/)
|
@@ -456,17 +456,17 @@ module Mail
|
|
456
456
|
|
457
457
|
def decoded_with_jpmobile
|
458
458
|
if @mobile
|
459
|
-
return value unless value =~
|
459
|
+
return value unless value =~ /=\?[^?]+\?([QB])\?[^?]*?\?=/mi
|
460
460
|
|
461
461
|
Encodings.collapse_adjacent_encodings(value).each {|line|
|
462
|
-
line.gsub!(
|
462
|
+
line.gsub!(/=\?[^?]+\?([QB])\?[^?]*?\?=/mi) do |string|
|
463
463
|
case Regexp.last_match(1)
|
464
464
|
when 'B', 'b' then decode_b_value_for_mobile(string)
|
465
465
|
when 'Q', 'q' then Encodings.q_value_decode(string)
|
466
466
|
else line
|
467
467
|
end
|
468
468
|
end
|
469
|
-
}.join
|
469
|
+
}.join
|
470
470
|
else
|
471
471
|
decoded_without_jpmobile
|
472
472
|
end
|
@@ -479,7 +479,7 @@ module Mail
|
|
479
479
|
alias_method :decoded, :decoded_with_jpmobile
|
480
480
|
|
481
481
|
def decode_b_value_for_mobile(str)
|
482
|
-
match = str.match(
|
482
|
+
match = str.match(/=\?(.+)?\?[Bb]\?(.*)\?=/m)
|
483
483
|
if match
|
484
484
|
charset = match[1]
|
485
485
|
str = Ruby19.decode_base64(match[2])
|
@@ -579,8 +579,8 @@ module Mail
|
|
579
579
|
|
580
580
|
def get_display_name_with_jpmobile
|
581
581
|
get_display_name_without_jpmobile
|
582
|
-
rescue NoMethodError =>
|
583
|
-
raise
|
582
|
+
rescue NoMethodError => e
|
583
|
+
raise e unless e.message.match?(/undefined method `gsub' for nil:NilClass/)
|
584
584
|
|
585
585
|
name = unquote(tree.display_name.text_value.strip.to_s)
|
586
586
|
strip_all_comments(name.to_s)
|
data/lib/jpmobile/mailer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'jpmobile/mail'
|
2
2
|
require 'jpmobile/lookup_context'
|
3
3
|
|
4
|
-
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp(?:[^a-zA-Z
|
4
|
+
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp(?:[^a-zA-Z.\-]|$)/)
|
5
5
|
|
6
6
|
module Jpmobile
|
7
7
|
module Mailer
|
data/lib/jpmobile/mobile/au.rb
CHANGED
@@ -6,9 +6,9 @@ module Jpmobile::Mobile
|
|
6
6
|
class Au < AbstractMobile
|
7
7
|
# 対応するUser-Agentの正規表現
|
8
8
|
# User-Agent文字列中に "UP.Browser" を含むVodafoneの端末があるので注意が必要
|
9
|
-
USER_AGENT_REGEXP = %r{^(?:KDDI|UP.Browser/.+?)-(.+?) }
|
9
|
+
USER_AGENT_REGEXP = %r{^(?:KDDI|UP.Browser/.+?)-(.+?) }.freeze
|
10
10
|
# 対応するメールアドレスの正規表現
|
11
|
-
MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp
|
11
|
+
MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp/.freeze
|
12
12
|
# 簡易位置情報取得に対応していないデバイスID
|
13
13
|
# http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
|
14
14
|
LOCATION_UNSUPPORTED_DEVICE_ID = %w[PT21 TS25 KCTE TST9 KCU1 SYT5 KCTD TST8 TST7 KCTC SYT4 KCTB KCTA TST6 KCT9 TST5 TST4 KCT8 SYT3 KCT7 MIT1 MAT3 KCT6 TST3 KCT5 KCT4 SYT2 MAT1 MAT2 TST2 KCT3 KCT2 KCT1 TST1 SYT1].freeze
|
@@ -4,7 +4,7 @@ module Jpmobile::Mobile
|
|
4
4
|
# スーパクラスはWillcom。
|
5
5
|
class Ddipocket < Willcom
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(DDIPOCKET}
|
7
|
+
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(DDIPOCKET}.freeze
|
8
8
|
|
9
9
|
MAIL_ADDRESS_REGEXP = nil # DdipocketはEmail判定だとWillcomと判定させたい
|
10
10
|
end
|
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
|
|
4
4
|
# ==DoCoMo携帯電話
|
5
5
|
class Docomo < AbstractMobile
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = /^DoCoMo
|
7
|
+
USER_AGENT_REGEXP = /^DoCoMo/.freeze
|
8
8
|
# 対応するメールアドレスの正規表現
|
9
|
-
MAIL_ADDRESS_REGEXP = /.+@docomo\.ne\.jp
|
9
|
+
MAIL_ADDRESS_REGEXP = /.+@docomo\.ne\.jp/.freeze
|
10
10
|
# メールのデフォルトのcharset
|
11
11
|
MAIL_CHARSET = 'Shift_JIS'.freeze
|
12
12
|
# テキスト部分の content-transfer-encoding
|
@@ -44,9 +44,8 @@ module Jpmobile::Mobile
|
|
44
44
|
# 端末製造番号があれば返す。無ければ +nil+ を返す。
|
45
45
|
def serial_number
|
46
46
|
case @env['HTTP_USER_AGENT']
|
47
|
-
when /ser([0-9a-zA-Z]{11})
|
48
|
-
|
49
|
-
when /ser([0-9a-zA-Z]{15});/ # FOMA
|
47
|
+
when /ser([0-9a-zA-Z]{11})$/, # mova
|
48
|
+
/ser([0-9a-zA-Z]{15});/ # FOMA
|
50
49
|
Regexp.last_match(1)
|
51
50
|
else
|
52
51
|
nil
|
@@ -160,9 +159,8 @@ module Jpmobile::Mobile
|
|
160
159
|
# モデル名を返す。
|
161
160
|
def model_name
|
162
161
|
case @env['HTTP_USER_AGENT']
|
163
|
-
when %r{^DoCoMo/2.0 (.+)\(}
|
164
|
-
|
165
|
-
when %r{^DoCoMo/1.0/(.+?)/}
|
162
|
+
when %r{^DoCoMo/2.0 (.+)\(},
|
163
|
+
%r{^DoCoMo/1.0/(.+?)/}
|
166
164
|
Regexp.last_match(1)
|
167
165
|
else
|
168
166
|
nil
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Jpmobile::Mobile
|
4
4
|
# ==EMOBILE携帯電話
|
5
5
|
class Emobile < AbstractMobile
|
6
|
-
USER_AGENT_REGEXP = %r{^emobile/|^Mozilla/5.0 \(H11T; like Gecko; OpenBrowser\) NetFront/3.4$|^Mozilla/4.0 \(compatible; MSIE 6.0; Windows CE; IEMobile 7.7\) S11HT$}
|
6
|
+
USER_AGENT_REGEXP = %r{^emobile/|^Mozilla/5.0 \(H11T; like Gecko; OpenBrowser\) NetFront/3.4$|^Mozilla/4.0 \(compatible; MSIE 6.0; Windows CE; IEMobile 7.7\) S11HT$}.freeze
|
7
7
|
# 対応するメールアドレスの正規表現
|
8
|
-
MAIL_ADDRESS_REGEXP = /.+@emnet\.ne\.jp
|
8
|
+
MAIL_ADDRESS_REGEXP = /.+@emnet\.ne\.jp/.freeze
|
9
9
|
# EMnet対応端末から通知されるユニークなユーザIDを取得する。
|
10
10
|
def em_uid
|
11
11
|
@request.env['HTTP_X_EM_UID']
|
data/lib/jpmobile/mobile/ipad.rb
CHANGED
@@ -5,9 +5,9 @@ module Jpmobile::Mobile
|
|
5
5
|
# Vodafoneのスーパクラス。
|
6
6
|
class Softbank < AbstractMobile
|
7
7
|
# 対応するuser-agentの正規表現
|
8
|
-
USER_AGENT_REGEXP = /^(?:SoftBank|Semulator)
|
8
|
+
USER_AGENT_REGEXP = /^(?:SoftBank|Semulator)/.freeze
|
9
9
|
# 対応するメールアドレスの正規表現 ディズニーモバイル対応
|
10
|
-
MAIL_ADDRESS_REGEXP = /.+@(?:softbank\.ne\.jp|disney\.ne\.jp)
|
10
|
+
MAIL_ADDRESS_REGEXP = /.+@(?:softbank\.ne\.jp|disney\.ne\.jp)/.freeze
|
11
11
|
# メールのデフォルトのcharset
|
12
12
|
MAIL_CHARSET = 'Shift_JIS'.freeze
|
13
13
|
# テキスト部分の content-transfer-encoding
|
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
|
|
4
4
|
# スーパクラスはSoftbank。
|
5
5
|
class Vodafone < Softbank
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = /^(Vodafone|Vemulator)
|
7
|
+
USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/.freeze
|
8
8
|
# 対応するメールアドレスの正規表現
|
9
|
-
MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp
|
9
|
+
MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp/.freeze
|
10
10
|
|
11
11
|
# cookieに対応しているか?
|
12
12
|
def supports_cookie?
|
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
|
|
4
4
|
# Ddipocketのスーパクラス。
|
5
5
|
class Willcom < AbstractMobile
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}
|
7
|
+
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}.freeze
|
8
8
|
# 対応するメールアドレスの正規表現
|
9
|
-
MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)
|
9
|
+
MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)/.freeze
|
10
10
|
|
11
11
|
# 位置情報があれば Position のインスタンスを返す。無ければ +nil+ を返す。
|
12
12
|
def position
|
@@ -10,10 +10,11 @@ module Jpmobile
|
|
10
10
|
if (mobile = env['rack.jpmobile']) && mobile.apply_params_filter?
|
11
11
|
# パラメータをkey, valueに分解
|
12
12
|
# form_params
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
if env['REQUEST_METHOD'] != 'GET' &&
|
14
|
+
env['REQUEST_METHOD'] != 'HEAD' &&
|
15
|
+
!env['CONTENT_TYPE'].match?(%r{application/json|application/xml})
|
16
|
+
|
17
|
+
env['rack.input'] = StringIO.new(parse_query(env['rack.input'].read, mobile))
|
17
18
|
end
|
18
19
|
|
19
20
|
# query_params
|
data/lib/jpmobile/rails.rb
CHANGED
@@ -4,24 +4,26 @@ ActiveSupport.on_load(:action_controller) do
|
|
4
4
|
require 'jpmobile/helpers'
|
5
5
|
require 'jpmobile/trans_sid'
|
6
6
|
require 'jpmobile/hook_test_request'
|
7
|
-
ActionDispatch::Request.
|
8
|
-
ActionDispatch::Request.
|
9
|
-
ActionController::Base.
|
10
|
-
ActionController::Base.
|
7
|
+
ActionDispatch::Request.prepend Jpmobile::Encoding
|
8
|
+
ActionDispatch::Request.include Jpmobile::RequestWithMobile
|
9
|
+
ActionController::Base.prepend Jpmobile::FallbackViewSelector
|
10
|
+
ActionController::Base.prepend Jpmobile::TransSidRedirecting
|
11
11
|
end
|
12
12
|
|
13
13
|
ActiveSupport.on_load(:action_view) do
|
14
14
|
require 'jpmobile/hook_action_view'
|
15
|
+
|
16
|
+
self.prepend Jpmobile::HtmlOptionsWithAcceptCharset
|
15
17
|
end
|
16
18
|
|
17
19
|
ActiveSupport.on_load(:after_initialize) do
|
18
20
|
case Rails.application.config.session_store.to_s
|
19
21
|
when 'ActionDispatch::Session::MemCacheStore'
|
20
22
|
require 'jpmobile/session/mem_cache_store'
|
21
|
-
ActionDispatch::Session::MemCacheStore.
|
23
|
+
ActionDispatch::Session::MemCacheStore.prepend Jpmobile::ParamsOverCookie
|
22
24
|
when 'ActionDispatch::Session::ActiveRecordStore'
|
23
25
|
require 'jpmobile/session/active_record_store'
|
24
|
-
ActionDispatch::Session::AbstractStore.
|
26
|
+
ActionDispatch::Session::AbstractStore.prepend Jpmobile::ParamsOverCookie
|
25
27
|
else
|
26
28
|
Rails.application.config.jpmobile.mount_session_store
|
27
29
|
end
|
@@ -31,39 +33,5 @@ ActiveSupport.on_load(:before_configuration) do
|
|
31
33
|
# MobileCarrierのみデフォルトで有効
|
32
34
|
config.middleware.insert_after ActionDispatch::Flash, ::Jpmobile::MobileCarrier
|
33
35
|
|
34
|
-
|
35
|
-
class Application
|
36
|
-
class Configuration
|
37
|
-
def jpmobile
|
38
|
-
@jpmobile ||= ::Jpmobile.config
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
module Jpmobile
|
46
|
-
module ViewSelector
|
47
|
-
def self.included(base)
|
48
|
-
base.class_eval do
|
49
|
-
before_action :register_mobile
|
50
|
-
|
51
|
-
self._view_paths = self._view_paths.dup
|
52
|
-
self.view_paths.unshift(*self.view_paths.map {|resolver| Jpmobile::Resolver.new(resolver.to_path) })
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def register_mobile
|
57
|
-
if request.mobile
|
58
|
-
# register mobile
|
59
|
-
self.lookup_context.mobile = request.mobile.variants
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def disable_mobile_view!
|
64
|
-
self.lookup_context.mobile = []
|
65
|
-
end
|
66
|
-
|
67
|
-
private :register_mobile, :disable_mobile_view!
|
68
|
-
end
|
36
|
+
Rails::Application::Configuration.include Jpmobile::Configuration::RailsConfiguration
|
69
37
|
end
|