Skip to content

Commit

Permalink
Not applying Filter/ParamsFilter for smart-phones
Browse files Browse the repository at this point in the history
  • Loading branch information
rust committed Sep 26, 2011
1 parent 88e35b3 commit 4efbf8f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/jpmobile/mobile/abstract_mobile.rb
Expand Up @@ -58,6 +58,16 @@ def smart_phone?
false
end

# Jpmobile::Rack::Filter を適用するかどうか
def apply_filter?
true
end

# Jpmobile::Rack::ParamsFilter を適用するかどうか
def apply_params_filter?
true
end

# エンコーディング変換用
def to_internal(str)
str
Expand Down
10 changes: 10 additions & 0 deletions lib/jpmobile/mobile/iphone.rb
Expand Up @@ -7,6 +7,16 @@ class Iphone < SmartPhone
# 対応するUser-Agentの正規表現
USER_AGENT_REGEXP = /iPhone/

# Jpmobile::Rack::Filter を適用する
def apply_filter?
true
end

# Jpmobile::Rack::ParamsFilter を適用する
def apply_params_filter?
true
end

# 文字コード変換
def to_internal(str)
# 絵文字を数値参照に変換
Expand Down
10 changes: 10 additions & 0 deletions lib/jpmobile/mobile/smart_phone.rb
Expand Up @@ -17,5 +17,15 @@ def supports_cookie?
def smart_phone?
true
end

# Jpmobile::Rack::Filter は適用しない
def apply_filter?
false
end

# Jpmobile::Rack::ParamsFilter は適用しない
def apply_params_filter?
false
end
end
end
2 changes: 1 addition & 1 deletion lib/jpmobile/rack/filter.rb
Expand Up @@ -15,7 +15,7 @@ def call(env)

status, env, response = @app.call(env)

if mobile and env['Content-Type'] =~ %r!text/html|application/xhtml\+xml!
if mobile and mobile.apply_filter? and env['Content-Type'] =~ %r!text/html|application/xhtml\+xml!
type, charset = env['Content-Type'].split(/;\s*charset=/)

body = response_to_body(response)
Expand Down
2 changes: 1 addition & 1 deletion lib/jpmobile/rack/params_filter.rb
Expand Up @@ -9,7 +9,7 @@ def initialize(app)

def call(env)
# 入力
if @mobile = env['rack.jpmobile']
if @mobile = env['rack.jpmobile'] and @mobile.apply_params_filter?
# パラメータをkey, valueに分解
# form_params
if env['REQUEST_METHOD'] == 'POST'
Expand Down

0 comments on commit 4efbf8f

Please sign in to comment.