Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape special characters (e.g. &) for XML requests #41

Closed
rubiii opened this issue Feb 28, 2010 · 8 comments
Closed

Escape special characters (e.g. &) for XML requests #41

rubiii opened this issue Feb 28, 2010 · 8 comments

Comments

@rubiii
Copy link
Contributor

rubiii commented Feb 28, 2010

this does not work

client = Savon::Client.new "http://example.com"
response = client.get_programs! do |soap|
  soap.namespace = "http://example.com"
  soap.body = { :username => "user", :password => "somePass21&" , :campaignid => 123 }
end

this does

xml = Builder::XmlMarkup.new
xml.username "user"
xml.password "somePass21&"
xml.campaignid 123

client = Savon::Client.new "http://example.com"
response = client.get_programs! do |soap|
  soap.namespace = "http://example.com"
  soap.body = xml.target!
end

(reported by luqman)

@rubiii
Copy link
Contributor Author

rubiii commented Feb 28, 2010

the problem here is, that the ampersand inside the password string is not escaped. will get this fixed with the next release.

@rubiii
Copy link
Contributor Author

rubiii commented Feb 28, 2010

@rubiii
Copy link
Contributor Author

rubiii commented Mar 21, 2010

released version 0.7.6 containg a fix for this problem. please update.

calamitas pushed a commit to calamitas/savon that referenced this issue Jun 7, 2011
@BrandonMathis
Copy link

Is there an option to turn off escaping of special characters? Can we add one if not?

There are wsdls whose elements have processContents="lax". This is typically used when the desired message content is raw xml which is not escaped and in read directly into the system/api.

@vkoivula
Copy link

vkoivula commented Jul 3, 2012

Is there any chance to turn off that escaping? I have XML in string, which breaks when escaped. I also put other data into the request as a hash, so manually typing all this into soap.xml would not be preferable. If you use first soap.body and then soap.xml the whole body is overwritten.. See below a shortened example.

soap.body = {
  "Example" => {
    "Foo" => "bar",
    "Bar" => "foo"
  },
  "XMLString" => xml_string
}

@rubiii
Copy link
Contributor Author

rubiii commented Jul 3, 2012

@vkoivula there's a way to prevent escaping of specific hash values by appending an apostroph to the key.

@vkoivula
Copy link

vkoivula commented Jul 4, 2012

@rubiii Thanks.

@supairish
Copy link

Does this method of escape preventing actually work in Version 2? It seems here https://github.com/savonrb/savon/blob/version2/lib/savon/qualified_message.rb#L22
that any key passed that ends with an exclamation gets the exclamation stripped off before it gets here
https://github.com/savonrb/savon/blob/version2/lib/savon/message.rb#L32

(rdb:1) Gyoku.xml_tag("requestXml!", :key_converter => @key_converter).to_s
"requestXml"

and thus escaping always happens.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants