Skip to content

Commit

Permalink
Remove utf8 check tag
Browse files Browse the repository at this point in the history
Signed-off-by: Shin-ichiro OGAWA <rust.stnard+git@gmail.com>
  • Loading branch information
rust committed Sep 29, 2010
1 parent bd9ecd3 commit 8cf9273
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/jpmobile/rack/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def call(env)
end

body = response_to_body(response)
body = body.sub(/<input name="utf8" type="hidden" value="#{[0x2713].pack("U")}"[^>]*?>/, ' ')
body = body.sub(/<input name="utf8" type="hidden" value="&#x2713;"[^>]*?>/, ' ')
body = body.gsub(/<input name="utf8" type="hidden" value="#{[0x2713].pack("U")}"[^>]*?>/, ' ')
body = body.gsub(/<input name="utf8" type="hidden" value="&#x2713;"[^>]*?>/, ' ')

response, charset = mobile.to_external(body, type, charset)

Expand Down
22 changes: 20 additions & 2 deletions spec/rack/jpmobile/filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,29 @@
end

it "_snowman が出力されないこと" do
res = Rack::MockRequest.env_for(
req = Rack::MockRequest.env_for(
"/",
"REQUEST_METHOD" => "GET",
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)')
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="&#x2713;" />'))).call(res)
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="&#x2713;" />'))).call(req)
res[1]['Content-Type'].should == "text/html; charset=Shift_JIS"
response_body(res).should == " "

res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="&#x2713;">'))).call(req)
res[1]['Content-Type'].should == "text/html; charset=Shift_JIS"
response_body(res).should == " "
end

it "Nokogiri 経由の _snowman が出力されないこと" do
req = Rack::MockRequest.env_for(
"/",
"REQUEST_METHOD" => "GET",
'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)')
res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::Filter.new(UnitApplication.new("<input name=\"utf8\" type=\"hidden\" value=\"#{[10003].pack("U")}\" />"))).call(req)
res[1]['Content-Type'].should == "text/html; charset=Shift_JIS"
response_body(res).should == " "

res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::Filter.new(UnitApplication.new("<input name=\"utf8\" type=\"hidden\" value=\"#{[10003].pack("U")}\">"))).call(req)
res[1]['Content-Type'].should == "text/html; charset=Shift_JIS"
response_body(res).should == " "
end
Expand Down

0 comments on commit 8cf9273

Please sign in to comment.