jpmobile 6.1.0 → 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/.onkcop-config.yml +0 -27
- data/.rubocop.yml +64 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +14 -11
- data/jpmobile.gemspec +3 -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 +10 -17
- data/lib/jpmobile/filter.rb +2 -2
- data/lib/jpmobile/mail.rb +4 -4
- data/lib/jpmobile/mailer.rb +1 -1
- data/lib/jpmobile/mobile/abstract_mobile.rb +1 -1
- data/lib/jpmobile/mobile/docomo.rb +4 -6
- data/lib/jpmobile/rack/params_filter.rb +5 -4
- data/lib/jpmobile/rails.rb +1 -35
- data/lib/jpmobile/util.rb +2 -3
- data/lib/jpmobile/version.rb +1 -1
- data/spec/rack_helper.rb +0 -4
- data/spec/unit/email_spec.rb +1 -1
- data/spec/unit/receive_mail_spec.rb +1 -1
- data/test/rails/overrides/Gemfile.jpmobile +1 -1
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +2 -2
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +9 -9
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d4fa2229a3c13898fc8b6606af673742dab9805d73e18805060a6eb107948a7
|
4
|
+
data.tar.gz: '0518495a8dc82eb71a58aa6623aeb1255920bcc602f0434b0a978f183c43f3ef'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f7102eefe118ccfb639a7f914b2fae3b904450b5a19e33ad3113b86b0fbeaf0be5932cffaae7f5b99d9ab1cdf07175ecc573043ebcf365f68ef97050e765a16
|
7
|
+
data.tar.gz: 13803d46396d2a0aec370b888566168b6399ab0ffc667e6600ce127bd1e9a7b1c6d563f42395c599ec891714d9dbb199ca860463b65c2145339f5c39ebdb635a
|
data/.onkcop-config.yml
CHANGED
@@ -122,29 +122,6 @@ Metrics/BlockLength:
|
|
122
122
|
- "config/routes/**/*.rb"
|
123
123
|
- "*.gemspec"
|
124
124
|
|
125
|
-
# 6 は強すぎるので緩める
|
126
|
-
Metrics/CyclomaticComplexity:
|
127
|
-
Max: 10
|
128
|
-
|
129
|
-
# * 警告 120文字
|
130
|
-
# * 禁止 160文字
|
131
|
-
# のイメージ
|
132
|
-
Layout/LineLength:
|
133
|
-
Max: 160
|
134
|
-
Exclude:
|
135
|
-
- "db/migrate/*.rb"
|
136
|
-
|
137
|
-
# 20 行超えるのは migration ファイル以外滅多に無い
|
138
|
-
Metrics/MethodLength:
|
139
|
-
Max: 20
|
140
|
-
Exclude:
|
141
|
-
- "db/migrate/*.rb"
|
142
|
-
|
143
|
-
# 分岐の数。ガード句を多用しているとデフォルト 7 だと厳しい
|
144
|
-
Metrics/PerceivedComplexity:
|
145
|
-
Max: 8
|
146
|
-
|
147
|
-
|
148
125
|
#################### Naming ################################
|
149
126
|
|
150
127
|
# has_ から始まるメソッドは許可する
|
@@ -202,10 +179,6 @@ Style/BlockDelimiters:
|
|
202
179
|
Exclude:
|
203
180
|
- "spec/**/*_spec.rb"
|
204
181
|
|
205
|
-
# option 等、明示的にハッシュにした方が分かりやすい場合もある
|
206
|
-
Style/BracesAroundHashParameters:
|
207
|
-
Enabled: false
|
208
|
-
|
209
182
|
# scope が違うとか親 module の存在確認が必要とかデメリットはあるが、
|
210
183
|
# namespace 付きのクラスはかなり頻繁に作るので簡単に書きたい。
|
211
184
|
Style/ClassAndModuleChildren:
|
data/.rubocop.yml
CHANGED
@@ -3,7 +3,7 @@ require: rubocop-performance
|
|
3
3
|
inherit_from: './.onkcop-config.yml'
|
4
4
|
|
5
5
|
AllCops:
|
6
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.5
|
7
7
|
Exclude:
|
8
8
|
- 'tmp/**/*'
|
9
9
|
- 'bin/*'
|
@@ -64,16 +64,20 @@ Metrics/AbcSize:
|
|
64
64
|
- 'lib/jpmobile/fallback_view_selector.rb'
|
65
65
|
- 'lib/jpmobile/resolver.rb'
|
66
66
|
- 'lib/jpmobile/rack/filter.rb'
|
67
|
+
- 'lib/jpmobile/trans_sid.rb'
|
67
68
|
|
68
69
|
Metrics/CyclomaticComplexity:
|
70
|
+
Max: 10
|
69
71
|
Exclude:
|
70
72
|
- 'lib/jpmobile/emoticon.rb'
|
71
73
|
- 'lib/jpmobile/helpers.rb'
|
72
74
|
- 'lib/jpmobile/mail.rb'
|
73
75
|
- 'lib/jpmobile/mobile/au.rb'
|
74
76
|
- 'lib/jpmobile/mobile/docomo.rb'
|
77
|
+
- 'lib/jpmobile/mobile/abstract_mobile.rb'
|
75
78
|
|
76
79
|
Metrics/PerceivedComplexity:
|
80
|
+
Max: 8
|
77
81
|
Exclude:
|
78
82
|
- 'lib/jpmobile/emoticon.rb'
|
79
83
|
- 'lib/jpmobile/helpers.rb'
|
@@ -81,8 +85,12 @@ Metrics/PerceivedComplexity:
|
|
81
85
|
- 'lib/jpmobile/mobile/au.rb'
|
82
86
|
- 'lib/jpmobile/mobile/docomo.rb'
|
83
87
|
- 'lib/jpmobile/trans_sid.rb'
|
88
|
+
- 'lib/jpmobile/filter.rb'
|
89
|
+
- 'lib/jpmobile/rack/filter.rb'
|
90
|
+
- 'lib/jpmobile/mobile/abstract_mobile.rb'
|
84
91
|
|
85
92
|
Layout/LineLength:
|
93
|
+
Max: 160
|
86
94
|
Exclude:
|
87
95
|
- '**/*_spec.rb'
|
88
96
|
- 'lib/jpmobile/emoticon/z_combine.rb'
|
@@ -115,6 +123,7 @@ Metrics/ClassLength:
|
|
115
123
|
- 'lib/jpmobile/mobile/docomo.rb'
|
116
124
|
|
117
125
|
Metrics/MethodLength:
|
126
|
+
Max: 20
|
118
127
|
Exclude:
|
119
128
|
- 'lib/jpmobile/emoticon.rb'
|
120
129
|
- 'lib/jpmobile/helpers.rb'
|
@@ -131,3 +140,57 @@ Lint/SuppressedException:
|
|
131
140
|
Lint/Void:
|
132
141
|
Exclude:
|
133
142
|
- 'lib/jpmobile/filter.rb'
|
143
|
+
|
144
|
+
Style/StringConcatenation:
|
145
|
+
Enabled: false
|
146
|
+
|
147
|
+
Layout/SpaceBeforeBrackets: # (new in 1.7)
|
148
|
+
Enabled: true
|
149
|
+
Exclude:
|
150
|
+
- '**/*_controller.rb'
|
151
|
+
- '**/*_spec.rb'
|
152
|
+
Lint/AmbiguousAssignment: # (new in 1.7)
|
153
|
+
Enabled: true
|
154
|
+
Lint/DuplicateBranch: # (new in 1.3)
|
155
|
+
Enabled: true
|
156
|
+
Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
|
157
|
+
Enabled: true
|
158
|
+
Lint/EmptyBlock: # (new in 1.1)
|
159
|
+
Enabled: true
|
160
|
+
Lint/EmptyClass: # (new in 1.3)
|
161
|
+
Enabled: true
|
162
|
+
Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
|
163
|
+
Enabled: true
|
164
|
+
Lint/ToEnumArguments: # (new in 1.1)
|
165
|
+
Enabled: true
|
166
|
+
Lint/UnexpectedBlockArity: # (new in 1.5)
|
167
|
+
Enabled: true
|
168
|
+
Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
|
169
|
+
Enabled: true
|
170
|
+
Style/ArgumentsForwarding: # (new in 1.1)
|
171
|
+
Enabled: true
|
172
|
+
Style/CollectionCompact: # (new in 1.2)
|
173
|
+
Enabled: true
|
174
|
+
Style/DocumentDynamicEvalDefinition: # (new in 1.1)
|
175
|
+
Enabled: true
|
176
|
+
Exclude:
|
177
|
+
- 'lib/jpmobile/path_set.rb'
|
178
|
+
Style/HashExcept: # (new in 1.7)
|
179
|
+
Enabled: true
|
180
|
+
Style/NegatedIfElseCondition: # (new in 1.2)
|
181
|
+
Enabled: true
|
182
|
+
Style/NilLambda: # (new in 1.3)
|
183
|
+
Enabled: true
|
184
|
+
Style/RedundantArgument: # (new in 1.4)
|
185
|
+
Enabled: true
|
186
|
+
Style/SwapValues: # (new in 1.1)
|
187
|
+
Enabled: true
|
188
|
+
|
189
|
+
Style/OptionalBooleanParameter:
|
190
|
+
Exclude:
|
191
|
+
- 'lib/jpmobile/emoticon.rb'
|
192
|
+
- 'lib/jpmobile/path_set.rb'
|
193
|
+
|
194
|
+
Metrics/ParameterLists:
|
195
|
+
Exclude:
|
196
|
+
- 'lib/jpmobile/path_set.rb'
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jpmobile (6.
|
4
|
+
jpmobile (6.1.1)
|
5
5
|
mail (~> 2.7.0)
|
6
6
|
rexml
|
7
7
|
scanf
|
@@ -96,7 +96,6 @@ GEM
|
|
96
96
|
hpricot (0.8.6)
|
97
97
|
i18n (1.8.5)
|
98
98
|
concurrent-ruby (~> 1.0)
|
99
|
-
jaro_winkler (1.5.4)
|
100
99
|
json (2.3.1)
|
101
100
|
loofah (2.8.0)
|
102
101
|
crass (~> 1.0.2)
|
@@ -114,7 +113,7 @@ GEM
|
|
114
113
|
nokogiri (1.10.10)
|
115
114
|
mini_portile2 (~> 2.4.0)
|
116
115
|
parallel (1.20.1)
|
117
|
-
parser (
|
116
|
+
parser (3.0.0.0)
|
118
117
|
ast (~> 2.4.1)
|
119
118
|
pry (0.13.1)
|
120
119
|
coderay (~> 1.1)
|
@@ -178,13 +177,17 @@ GEM
|
|
178
177
|
rspec-mocks (~> 3.9)
|
179
178
|
rspec-support (~> 3.9)
|
180
179
|
rspec-support (3.10.0)
|
181
|
-
rubocop (
|
182
|
-
jaro_winkler (~> 1.5.1)
|
180
|
+
rubocop (1.7.0)
|
183
181
|
parallel (~> 1.10)
|
184
|
-
parser (>= 2.7.
|
182
|
+
parser (>= 2.7.1.5)
|
185
183
|
rainbow (>= 2.2.2, < 4.0)
|
184
|
+
regexp_parser (>= 1.8, < 3.0)
|
185
|
+
rexml
|
186
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
186
187
|
ruby-progressbar (~> 1.7)
|
187
|
-
unicode-display_width (>= 1.4.0, <
|
188
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
189
|
+
rubocop-ast (1.3.0)
|
190
|
+
parser (>= 2.7.1.5)
|
188
191
|
rubocop-performance (1.5.2)
|
189
192
|
rubocop (>= 0.71.0)
|
190
193
|
ruby-progressbar (1.10.1)
|
@@ -202,7 +205,7 @@ GEM
|
|
202
205
|
thor (1.0.1)
|
203
206
|
tzinfo (2.0.3)
|
204
207
|
concurrent-ruby (~> 1.0)
|
205
|
-
unicode-display_width (1.
|
208
|
+
unicode-display_width (1.7.0)
|
206
209
|
websocket-driver (0.7.3)
|
207
210
|
websocket-extensions (>= 0.1.0)
|
208
211
|
websocket-extensions (0.1.5)
|
@@ -225,9 +228,9 @@ DEPENDENCIES
|
|
225
228
|
rspec
|
226
229
|
rspec-its
|
227
230
|
rspec-rails
|
228
|
-
rubocop
|
229
|
-
rubocop-performance
|
231
|
+
rubocop
|
232
|
+
rubocop-performance
|
230
233
|
sqlite3-ruby
|
231
234
|
|
232
235
|
BUNDLED WITH
|
233
|
-
2.2.
|
236
|
+
2.2.3
|
data/jpmobile.gemspec
CHANGED
@@ -16,9 +16,11 @@ 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.required_ruby_version = '>= 2.5.0'
|
20
|
+
|
19
21
|
gem.add_dependency 'mail', '~> 2.7.0'
|
20
|
-
gem.add_dependency 'scanf'
|
21
22
|
gem.add_dependency 'rexml'
|
23
|
+
gem.add_dependency 'scanf'
|
22
24
|
gem.add_development_dependency 'capybara-webkit'
|
23
25
|
gem.add_development_dependency 'geokit'
|
24
26
|
gem.add_development_dependency 'git'
|
data/lib/jpmobile.rb
CHANGED
@@ -63,6 +63,7 @@ module Jpmobile
|
|
63
63
|
autoload :Mailer, 'jpmobile/mailer'
|
64
64
|
autoload :Resolver, 'jpmobile/resolver'
|
65
65
|
|
66
|
+
autoload :ViewSelector, 'jpmobile/view_selector'
|
66
67
|
autoload :FallbackViewSelector, 'jpmobile/fallback_view_selector'
|
67
68
|
|
68
69
|
autoload :ParamsOverCookie, 'jpmobile/trans_sid'
|
@@ -2,9 +2,7 @@ module Jpmobile
|
|
2
2
|
class Configuration
|
3
3
|
include Singleton
|
4
4
|
|
5
|
-
attr_accessor :form_accept_charset_conversion
|
6
|
-
attr_accessor :smart_phone_emoticon_compatibility
|
7
|
-
attr_accessor :fallback_view_selector
|
5
|
+
attr_accessor :form_accept_charset_conversion, :smart_phone_emoticon_compatibility, :fallback_view_selector
|
8
6
|
|
9
7
|
def initialize
|
10
8
|
@form_accept_charset_conversion = false
|
@@ -23,5 +21,11 @@ module Jpmobile
|
|
23
21
|
def mount_session_store
|
24
22
|
@session_store && @session_store.call
|
25
23
|
end
|
24
|
+
|
25
|
+
module RailsConfiguration
|
26
|
+
def jpmobile
|
27
|
+
@jpmobile ||= ::Jpmobile.config
|
28
|
+
end
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
data/lib/jpmobile/docomo_guid.rb
CHANGED
@@ -30,8 +30,8 @@ module Jpmobile::DocomoGuid #:nodoc:
|
|
30
30
|
return false unless request.mobile.is_a?(Jpmobile::Mobile::Docomo)
|
31
31
|
return false if not_apply_guid_user_agent?
|
32
32
|
|
33
|
-
if docomo_guid_mode == :valid_ip
|
34
|
-
return false
|
33
|
+
if docomo_guid_mode == :valid_ip && !request.mobile.valid_ip?
|
34
|
+
return false
|
35
35
|
end
|
36
36
|
|
37
37
|
true
|
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
@@ -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
|
data/lib/jpmobile/filter.rb
CHANGED
@@ -54,8 +54,8 @@ module Jpmobile
|
|
54
54
|
private
|
55
55
|
|
56
56
|
def replace_chars(str, table)
|
57
|
-
@regexp_cache ||= {}
|
58
|
-
str.gsub(@regexp_cache[table
|
57
|
+
@regexp_cache ||= {}.compare_by_identity
|
58
|
+
str.gsub(@regexp_cache[table] ||= Regexp.union(table.keys), table)
|
59
59
|
end
|
60
60
|
|
61
61
|
def han_to_zen_table
|
data/lib/jpmobile/mail.rb
CHANGED
@@ -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])
|
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
|
@@ -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
|
@@ -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
@@ -33,39 +33,5 @@ ActiveSupport.on_load(:before_configuration) do
|
|
33
33
|
# MobileCarrierのみデフォルトで有効
|
34
34
|
config.middleware.insert_after ActionDispatch::Flash, ::Jpmobile::MobileCarrier
|
35
35
|
|
36
|
-
|
37
|
-
class Application
|
38
|
-
class Configuration
|
39
|
-
def jpmobile
|
40
|
-
@jpmobile ||= ::Jpmobile.config
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
module Jpmobile
|
48
|
-
module ViewSelector
|
49
|
-
def self.included(base)
|
50
|
-
base.class_eval do
|
51
|
-
before_action :register_mobile
|
52
|
-
|
53
|
-
self._view_paths = self._view_paths.dup
|
54
|
-
self.view_paths.unshift(*self.view_paths.map {|resolver| Jpmobile::Resolver.new(resolver.to_path) })
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def register_mobile
|
59
|
-
if request.mobile
|
60
|
-
# register mobile
|
61
|
-
self.lookup_context.mobile = request.mobile.variants
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def disable_mobile_view!
|
66
|
-
self.lookup_context.mobile = []
|
67
|
-
end
|
68
|
-
|
69
|
-
private :register_mobile, :disable_mobile_view!
|
70
|
-
end
|
36
|
+
Rails::Application::Configuration.include Jpmobile::Configuration::RailsConfiguration
|
71
37
|
end
|
data/lib/jpmobile/util.rb
CHANGED
@@ -255,9 +255,8 @@ module Jpmobile
|
|
255
255
|
SJIS
|
256
256
|
when ::Encoding::UTF_8
|
257
257
|
UTF8
|
258
|
-
when ::Encoding::ASCII_8BIT
|
259
|
-
BINARY
|
260
258
|
else
|
259
|
+
# 上記以外はすべて BINARY 扱い
|
261
260
|
BINARY
|
262
261
|
end
|
263
262
|
end
|
@@ -297,7 +296,7 @@ module Jpmobile
|
|
297
296
|
|
298
297
|
def invert_table(hash)
|
299
298
|
result = {}
|
300
|
-
hash.
|
299
|
+
hash.each_key do |key|
|
301
300
|
if result[hash[key]]
|
302
301
|
if !key.is_a?(Array) && !result[hash[key]].is_a?(Array) && result[hash[key]] > key
|
303
302
|
result[hash[key]] = key
|
data/lib/jpmobile/version.rb
CHANGED
data/spec/rack_helper.rb
CHANGED
@@ -75,8 +75,6 @@ module Jpmobile::RackHelper
|
|
75
75
|
body = case res
|
76
76
|
when Array
|
77
77
|
res[2]
|
78
|
-
when String
|
79
|
-
res.body
|
80
78
|
else
|
81
79
|
res.body
|
82
80
|
end
|
@@ -84,8 +82,6 @@ module Jpmobile::RackHelper
|
|
84
82
|
case body
|
85
83
|
when Array
|
86
84
|
body.first
|
87
|
-
when String
|
88
|
-
body
|
89
85
|
else
|
90
86
|
body
|
91
87
|
end
|
data/spec/unit/email_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe 'Jpmobile::Email' do
|
|
56
56
|
|
57
57
|
describe 'japanese_mail_address_regexp' do
|
58
58
|
before do
|
59
|
-
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp(?:[^a-zA-Z
|
59
|
+
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp(?:[^a-zA-Z.\-]|$)/)
|
60
60
|
end
|
61
61
|
|
62
62
|
it '#detect_from_mail_header should return Jpmobile::Mobile::AbstractMobile when the header contains .jp address' do
|
@@ -7,7 +7,7 @@ describe 'Jpmobile::Mail#receive' do
|
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
@to = 'info@jpmobile-rails.org'
|
10
|
-
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z
|
10
|
+
Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp[^a-zA-Z.\-]/)
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'PC mail' do
|
@@ -4,7 +4,7 @@ gem 'jpmobile', path: './vendor/jpmobile'
|
|
4
4
|
gem 'jpmobile-terminfo', path: './vendor/jpmobile-terminfo'
|
5
5
|
gem 'jpmobile-ipaddresses', path: './vendor/jpmobile-ipaddresses'
|
6
6
|
|
7
|
-
gem 'activerecord-session_store', '
|
7
|
+
gem 'activerecord-session_store', git: 'https://github.com/rails/activerecord-session_store.git', ref: 'f188efbc49a522123cc8acc805143824176d01c1'
|
8
8
|
|
9
9
|
gem 'pry'
|
10
10
|
gem 'pry-byebug'
|
@@ -6,7 +6,7 @@ shared_examples_for 'docomo_guid が起動しないとき' do
|
|
6
6
|
it 'で link_to の自動書き換えが行われない' do
|
7
7
|
get :link
|
8
8
|
|
9
|
-
expect(response.body).to match(%r{href
|
9
|
+
expect(response.body).to match(%r{href=".+/link"})
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ shared_examples_for 'docomo_guid が起動するとき' do
|
|
14
14
|
it 'で link_to の自動書き換えが行われる' do
|
15
15
|
get :link
|
16
16
|
|
17
|
-
expect(response.body).to match(%r{href
|
17
|
+
expect(response.body).to match(%r{href=".+/link\?guid=ON"})
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -27,12 +27,12 @@ describe 'trans_sid functional', type: :request do
|
|
27
27
|
it 'で link_to の自動書き換えが行われない' do
|
28
28
|
res = get_with_session(@controller, 'link', @user_agent)
|
29
29
|
|
30
|
-
expect(res.response.body).to match(%r{<a href
|
30
|
+
expect(res.response.body).to match(%r{<a href="/.+?/link">linkto</a>})
|
31
31
|
end
|
32
32
|
it 'で form の自動書き換えが行われない' do
|
33
33
|
res = get_with_session(@controller, 'form', @user_agent)
|
34
34
|
|
35
|
-
expect(res.response.body).to match(%r{<form.*action
|
35
|
+
expect(res.response.body).to match(%r{<form.*action="/.+?/form".*accept-charset="#{@charset}"})
|
36
36
|
end
|
37
37
|
it 'で redirect の自動書き換えが行われない' do
|
38
38
|
res = get_with_session(@controller, 'redirect', @user_agent)
|
@@ -45,16 +45,16 @@ describe 'trans_sid functional', type: :request do
|
|
45
45
|
it 'で link_to の自動書き換えが行われる' do
|
46
46
|
res = get_with_session(@controller, 'link', @user_agent)
|
47
47
|
|
48
|
-
expect(res.response.body).to match(%r{<a href
|
48
|
+
expect(res.response.body).to match(%r{<a href="/.+?/link\?_session_id=[a-zA-Z0-9]{32}">linkto</a>})
|
49
49
|
end
|
50
50
|
it 'で form内にhiddenが差し込まれる' do
|
51
51
|
res = get_with_session(@controller, 'form', @user_agent)
|
52
|
-
expect(res.response.body).to match(/<input type
|
52
|
+
expect(res.response.body).to match(/<input type="hidden" name=".+" value="[a-zA-Z0-9]{32}"/)
|
53
53
|
end
|
54
54
|
it 'で form の自動書き換えが行われる' do
|
55
55
|
res = get_with_session(@controller, 'form', @user_agent)
|
56
56
|
|
57
|
-
expect(res.response.body).to match(%r{<form.*action
|
57
|
+
expect(res.response.body).to match(%r{<form.*action="/.+?/form\?_session_id=[a-zA-Z0-9]{32}".*accept-charset="#{@charset}"})
|
58
58
|
end
|
59
59
|
it 'で redirect の自動書き換えが行われる' do
|
60
60
|
res = get_with_session(@controller, 'redirect', @user_agent)
|
@@ -66,12 +66,12 @@ describe 'trans_sid functional', type: :request do
|
|
66
66
|
it 'で @user の link_to の自動書き換えが行われる' do
|
67
67
|
res = get_with_session(@controller, 'link_path', @user_agent)
|
68
68
|
|
69
|
-
expect(res.response.body).to match(%r{<a href
|
69
|
+
expect(res.response.body).to match(%r{<a href="/users/1\?_session_id=[a-zA-Z0-9]{32}">linkto</a>})
|
70
70
|
end
|
71
71
|
it 'で @user の form の自動書き換えが行われる' do
|
72
72
|
res = get_with_session(@controller, 'form_path', @user_agent)
|
73
73
|
|
74
|
-
expect(res.response.body).to match(%r{<form.*action
|
74
|
+
expect(res.response.body).to match(%r{<form.*action="/users/1\?_session_id=[a-zA-Z0-9]{32}".*accept-charset="#{@charset}"})
|
75
75
|
end
|
76
76
|
it 'で @path の redirect の自動書き換えが行われる' do
|
77
77
|
res = get_with_session(@controller, 'redirect_path', @user_agent)
|
@@ -83,12 +83,12 @@ describe 'trans_sid functional', type: :request do
|
|
83
83
|
it 'で [:admin, @user] の link_to の自動書き換えが行われる' do
|
84
84
|
res = get_with_session(@controller, 'link_path_admin', @user_agent)
|
85
85
|
|
86
|
-
expect(res.response.body).to match(%r{<a href
|
86
|
+
expect(res.response.body).to match(%r{<a href="/admin/users/1\?_session_id=[a-zA-Z0-9]{32}">linkto</a>})
|
87
87
|
end
|
88
88
|
it 'で [:admin, @user] の form の自動書き換えが行われる' do
|
89
89
|
res = get_with_session(@controller, 'form_path_admin', @user_agent)
|
90
90
|
|
91
|
-
expect(res.response.body).to match(%r{<form.*action
|
91
|
+
expect(res.response.body).to match(%r{<form.*action="/admin/users/1\?_session_id=[a-zA-Z0-9]{32}".* accept-charset="#{@charset}"})
|
92
92
|
end
|
93
93
|
it 'で [:admin, @path] の redirect の自動書き換えが行われる' do
|
94
94
|
res = get_with_session(@controller, 'redirect_path_admin', @user_agent)
|
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: 6.1.
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shin-ichiro OGAWA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-12-
|
12
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 2.7.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rexml
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: scanf
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -478,7 +478,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
478
478
|
requirements:
|
479
479
|
- - ">="
|
480
480
|
- !ruby/object:Gem::Version
|
481
|
-
version:
|
481
|
+
version: 2.5.0
|
482
482
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
483
483
|
requirements:
|
484
484
|
- - ">="
|