Permalink
Browse files

we should respect charset for incoming messages and not assuming inco…

…ming is

always UTF-8, and only force UTF-8 for our response.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1842 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 367d2e3 commit 03d91590258e7cc6e27a8b0c1dc21ff93b70884a @bitserf bitserf committed Jul 16, 2005
Showing with 12 additions and 2 deletions.
  1. +12 −2 actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
View
14 actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
@@ -28,9 +28,10 @@ def self.create(controller)
def decode_action_pack_request(action_pack_request)
return nil unless soap_action = has_valid_soap_action?(action_pack_request)
service_name = action_pack_request.parameters['action']
+ input_encoding = parse_charset(action_pack_request.env['HTTP_CONTENT_TYPE'])
protocol_options = {
:soap_action => soap_action,
- :charset => AWSEncoding
+ :charset => input_encoding
}
decode_request(action_pack_request.raw_post, service_name, protocol_options)
end
@@ -42,7 +43,7 @@ def encode_action_pack_request(service_name, public_method_name, raw_body, optio
end
def decode_request(raw_request, service_name, protocol_options={})
- envelope = SOAP::Processor.unmarshal(raw_request, :charset => AWSEncoding)
+ envelope = SOAP::Processor.unmarshal(raw_request, :charset => protocol_options[:charset])
unless envelope
raise ProtocolError, "Failed to parse SOAP request message"
end
@@ -151,6 +152,15 @@ def create_soap_envelope(body)
body = SOAP::SOAPBody.new(body)
SOAP::SOAPEnvelope.new(header, body)
end
+
+ def parse_charset(content_type)
+ return AWSEncoding if content_type.nil?
+ if /^text\/xml(?:\s*;\s*charset=([^"]+|"[^"]+"))$/i =~ content_type
+ $1
+ else
+ AWSEncoding
+ end
+ end
end
end
end

0 comments on commit 03d9159

Please sign in to comment.