aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice
diff options
context:
space:
mode:
authorLeon Breedt <bitserf@gmail.com>2005-07-16 21:08:27 +0000
committerLeon Breedt <bitserf@gmail.com>2005-07-16 21:08:27 +0000
commit03d91590258e7cc6e27a8b0c1dc21ff93b70884a (patch)
tree3e51de97d00c202bb5f8d35ec3e91d252ba0dbc5 /actionwebservice
parent367d2e3cfce3c9e91aa358e05fb0f2c8bb132f6f (diff)
downloadrails-03d91590258e7cc6e27a8b0c1dc21ff93b70884a.tar.gz
rails-03d91590258e7cc6e27a8b0c1dc21ff93b70884a.tar.bz2
rails-03d91590258e7cc6e27a8b0c1dc21ff93b70884a.zip
we should respect charset for incoming messages and not assuming incoming 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
Diffstat (limited to 'actionwebservice')
-rw-r--r--actionwebservice/lib/action_web_service/protocol/soap_protocol.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb b/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
index 89f222f908..b28d57d00e 100644
--- a/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
+++ b/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb
@@ -28,9 +28,10 @@ module ActionWebService # :nodoc:
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 @@ module ActionWebService # :nodoc:
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 @@ module ActionWebService # :nodoc:
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